@erenthedeveloper0/zen-middleware 0.1.0-alpha.4 → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/request-id.ts +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erenthedeveloper0/zen-middleware",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "Zen first-party middleware: CORS, security headers, request ids and rate limiting, as hooks that also run on unmatched requests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cors",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"test": "node --test \"test/**/*.test.ts\""
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@erenthedeveloper0/zen-core": "0.1.0-alpha.
|
|
55
|
+
"@erenthedeveloper0/zen-core": "0.1.0-alpha.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"typescript": ">=5.0"
|
package/src/request-id.ts
CHANGED
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
* Request id — rfcs/0001 §19.4, §31.1.
|
|
8
8
|
*
|
|
9
9
|
* Zen already generates one: the dispatcher assigns `ctx.id` before the first
|
|
10
|
-
* hook runs, so the RFC 9457 problem document
|
|
11
|
-
* lines
|
|
12
|
-
*
|
|
13
|
-
* §28.8 — so a handler adds `requestId: ctx.id` itself.) This adds the two
|
|
10
|
+
* hook runs, so the RFC 9457 problem document, the framework's own error log
|
|
11
|
+
* lines and every line written through `ctx.log` — bound to the request, §31.1
|
|
12
|
+
* — already carry a correlation key with no plugin at all. This adds the two
|
|
14
13
|
* halves that need a decision rather than a default.
|
|
15
14
|
*
|
|
16
15
|
* ### Echoing it
|
|
@@ -43,11 +42,12 @@ import {
|
|
|
43
42
|
/**
|
|
44
43
|
* The one field this plugin writes.
|
|
45
44
|
*
|
|
46
|
-
* `ctx.id` is `readonly` on `BaseContext` and
|
|
47
|
-
* assigned
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
45
|
+
* `ctx.id` is `readonly` on `BaseContext` and an accessor on both twins,
|
|
46
|
+
* assigned by the dispatcher. Overwriting it stores the id in a field every
|
|
47
|
+
* context already has and drops the logger `ctx.log` bound to the old one, so
|
|
48
|
+
* every line written after it carries the adopted id; no field is added and I2
|
|
49
|
+
* is untouched (§7.6). It is still the only place in this package that writes
|
|
50
|
+
* to a context, and naming the type is how that stays deliberate.
|
|
51
51
|
*
|
|
52
52
|
* The alternative was a second id on a slot, and it is worse in the way that
|
|
53
53
|
* matters: two ids means every log line, every problem document and every
|