@nifrajs/core 2.8.2 → 2.9.1

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.
Files changed (79) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/internal/route-execution.d.ts +8 -2
  4. package/dist/internal/route-execution.d.ts.map +1 -1
  5. package/dist/node-direct.d.ts.map +1 -1
  6. package/dist/node-direct.js +3 -1
  7. package/dist/node-direct.js.map +1 -1
  8. package/dist/router/router.d.ts.map +1 -1
  9. package/dist/router/router.js +26 -6
  10. package/dist/router/router.js.map +1 -1
  11. package/dist/server/context.d.ts +2 -0
  12. package/dist/server/context.d.ts.map +1 -1
  13. package/dist/server/cookies.d.ts.map +1 -1
  14. package/dist/server/cookies.js +4 -1
  15. package/dist/server/cookies.js.map +1 -1
  16. package/dist/server/http.d.ts.map +1 -1
  17. package/dist/server/http.js +16 -3
  18. package/dist/server/http.js.map +1 -1
  19. package/dist/server/node-outcome-hook.d.ts +78 -1
  20. package/dist/server/node-outcome-hook.d.ts.map +1 -1
  21. package/dist/server/node-outcome-hook.js +197 -1
  22. package/dist/server/node-outcome-hook.js.map +1 -1
  23. package/dist/server/node-outcome.d.ts +22 -2
  24. package/dist/server/node-outcome.d.ts.map +1 -1
  25. package/dist/server/node-outcome.js +86 -11
  26. package/dist/server/node-outcome.js.map +1 -1
  27. package/dist/server/query.d.ts +2 -0
  28. package/dist/server/query.d.ts.map +1 -1
  29. package/dist/server/query.js +27 -1
  30. package/dist/server/query.js.map +1 -1
  31. package/dist/server/request-context.d.ts +8 -1
  32. package/dist/server/request-context.d.ts.map +1 -1
  33. package/dist/server/request-context.js +23 -2
  34. package/dist/server/request-context.js.map +1 -1
  35. package/dist/server/respond.d.ts +29 -3
  36. package/dist/server/respond.d.ts.map +1 -1
  37. package/dist/server/respond.js +279 -16
  38. package/dist/server/respond.js.map +1 -1
  39. package/dist/server/response-contract-lane.d.ts +17 -3
  40. package/dist/server/response-contract-lane.d.ts.map +1 -1
  41. package/dist/server/response-contract-lane.js +6 -3
  42. package/dist/server/response-contract-lane.js.map +1 -1
  43. package/dist/server/server-types.d.ts +37 -0
  44. package/dist/server/server-types.d.ts.map +1 -1
  45. package/dist/server/server.d.ts +151 -7
  46. package/dist/server/server.d.ts.map +1 -1
  47. package/dist/server/server.js +1163 -174
  48. package/dist/server/server.js.map +1 -1
  49. package/dist/server/static-headers.d.ts +47 -0
  50. package/dist/server/static-headers.d.ts.map +1 -0
  51. package/dist/server/static-headers.js +109 -0
  52. package/dist/server/static-headers.js.map +1 -0
  53. package/dist/server.d.ts +2 -1
  54. package/dist/server.d.ts.map +1 -1
  55. package/dist/server.js +1 -0
  56. package/dist/server.js.map +1 -1
  57. package/dist/transport-codec.d.ts +15 -0
  58. package/dist/transport-codec.d.ts.map +1 -1
  59. package/dist/transport-codec.js +49 -10
  60. package/dist/transport-codec.js.map +1 -1
  61. package/package.json +1 -1
  62. package/src/index.ts +1 -1
  63. package/src/internal/route-execution.ts +19 -1
  64. package/src/node-direct.ts +7 -1
  65. package/src/router/router.ts +24 -6
  66. package/src/server/context.ts +2 -0
  67. package/src/server/cookies.ts +4 -1
  68. package/src/server/http.ts +16 -3
  69. package/src/server/node-outcome-hook.ts +315 -1
  70. package/src/server/node-outcome.ts +100 -14
  71. package/src/server/query.ts +26 -1
  72. package/src/server/request-context.ts +23 -1
  73. package/src/server/respond.ts +386 -17
  74. package/src/server/response-contract-lane.ts +17 -3
  75. package/src/server/server-types.ts +42 -0
  76. package/src/server/server.ts +1618 -237
  77. package/src/server/static-headers.ts +142 -0
  78. package/src/server.ts +9 -0
  79. package/src/transport-codec.ts +55 -10
@@ -5,13 +5,39 @@
5
5
  */
6
6
  import { type HandlerResult } from "./runtime-core.js";
7
7
  import type { CtxSet, RawContext } from "./server.js";
8
+ import { type StaticResponseHeaders } from "./static-headers.js";
9
+ /**
10
+ * Build the per-server shapes for a validated static header record. The JSON init is prebuilt once
11
+ * here so a static-middleware app's fused JSON lane pays a shared init read instead of a header write
12
+ * per declared name per request - the same reuse the hook-free lane already gets from
13
+ * {@link JSON_INIT_200}.
14
+ */
15
+ export declare function buildStaticResponseHeaders(record: Readonly<Record<string, string>>): StaticResponseHeaders;
16
+ /**
17
+ * Apply the static defaults to an ALREADY-BUILT response - the framework's error/404/timeout renders
18
+ * and a handler-returned `Response`, none of which go through the header init below. Defaults, so a
19
+ * name the response already carries is left alone. A guarded `Headers` (a raw `fetch()` result a
20
+ * handler returned) rejects every write, so the first `set` throws with nothing applied and the
21
+ * retry lands on a mutable copy.
22
+ */
23
+ export declare function applyStaticResponseHeaders(response: Response, statics: StaticResponseHeaders): Response;
24
+ export declare function knownMutableHeaders(headers: Headers): boolean;
25
+ export declare function rememberMutableHeaders(headers: Headers): void;
26
+ /** Normalize handler-produced bodyless responses before response middleware sees them. */
27
+ export declare function normalizeBodylessResponse(response: Response): Response;
28
+ type ResponseBodyTagOption = false | true | object | undefined;
29
+ /** The framework-serialized bytes riding a tagged Response, or `undefined` for raw/streamed ones. */
30
+ export declare function taggedResponseBody(response: Response, owners?: ReadonlySet<object>): string | Uint8Array | undefined;
31
+ export declare function taggedResponseOwner(response: Response): object | undefined;
32
+ export declare function markTaggedResponse(response: Response, body: string | Uint8Array, owner?: object): Response;
8
33
  /** Fused-lane respond when `c.set` is untouched. Bun 1.3's native `Response.json` now beats the
9
34
  * older hand-inlined stringify + Response construction on this lane while preserving the exact
10
35
  * body/content-type contract; keep the generic fallback for non-JSON values. */
11
- export declare function fusedRespondNoSet(result: unknown): Response;
36
+ export declare function fusedRespondNoSet(result: unknown, tagResponseBody?: ResponseBodyTagOption, statics?: StaticResponseHeaders): Response;
12
37
  /** Fused-lane respond with a context: read `c.set` once; untouched (the common case) -> the fast
13
38
  * JSON respond; touched -> the generic `toResponse` with those controls (statuses, headers, cookies). */
14
- export declare function fusedRespond(result: unknown, ctx: RawContext): Response;
15
- export declare function toResponse(result: HandlerResult, set: CtxSet): Response;
39
+ export declare function fusedRespond(result: unknown, ctx: RawContext, tagResponseBody?: ResponseBodyTagOption, statics?: StaticResponseHeaders): Response;
40
+ export declare function toResponse(result: HandlerResult, set: CtxSet, tagResponseBody?: ResponseBodyTagOption, statics?: StaticResponseHeaders): Response;
16
41
  export declare function appendCookiesToResponse(response: Response, set: CtxSet): Response;
42
+ export {};
17
43
  //# sourceMappingURL=respond.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"respond.d.ts","sourceRoot":"","sources":["../../src/server/respond.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAqBrD;;gFAEgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,CAW3D;AAED;yGACyG;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,QAAQ,CAIvE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAwBvE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAUjF"}
1
+ {"version":3,"file":"respond.d.ts","sourceRoot":"","sources":["../../src/server/respond.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAA2B,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAoBzF;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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qB,GAC9B,QAAQ,CAiEV;AAsBD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAUjF"}
@@ -4,6 +4,7 @@
4
4
  * spine types, so the wire-response format lives in one module distinct from the request engine.
5
5
  */
6
6
  import { CONTEXT_SET, EMPTY_RESPONSE_CONTROLS, isResponseResult, } from "./runtime-core.js";
7
+ import { mergeStaticHeaderRecord } from "./static-headers.js";
7
8
  /** Build the response headers init. The common path (no `c.set`) returns `undefined` so `Response`
8
9
  * gets no `headers` at all. Cookies force a `Headers` object - multiple `Set-Cookie`s can't live in a
9
10
  * `Record<string,string>` (the 2nd would overwrite the 1st), so they're `append`ed individually. */
@@ -19,52 +20,314 @@ function headersInit(set) {
19
20
  // Keep the fast JSON respond path byte-identical to `Response.json` without probing it at module
20
21
  // scope: workerd forbids `Response.json()` during startup. A shared `Headers` is safe to reuse
21
22
  // across responses: the Response constructor copies `init.headers` into its own list.
22
- const JSON_CT_HEADERS = new Headers({
23
- "content-type": "application/json;charset=utf-8",
24
- });
23
+ const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
24
+ const JSON_CT_HEADERS = new Headers({ "content-type": JSON_CONTENT_TYPE });
25
25
  const JSON_INIT_200 = { status: 200, headers: JSON_CT_HEADERS };
26
+ /**
27
+ * Build the per-server shapes for a validated static header record. The JSON init is prebuilt once
28
+ * here so a static-middleware app's fused JSON lane pays a shared init read instead of a header write
29
+ * per declared name per request - the same reuse the hook-free lane already gets from
30
+ * {@link JSON_INIT_200}.
31
+ */
32
+ export function buildStaticResponseHeaders(record) {
33
+ const frozen = Object.freeze({ ...record });
34
+ const jsonHeaders = new Headers({ ...frozen, "content-type": JSON_CONTENT_TYPE });
35
+ let responseJson;
36
+ return {
37
+ record: frozen,
38
+ entries: Object.freeze(Object.entries(frozen)),
39
+ jsonHeaders,
40
+ jsonInit200: { status: 200, headers: jsonHeaders },
41
+ responseJsonInit200: () => {
42
+ responseJson ??= {
43
+ status: 200,
44
+ headers: new Headers({ ...frozen, "content-type": responseJsonContentType() }),
45
+ };
46
+ return responseJson;
47
+ },
48
+ };
49
+ }
50
+ /**
51
+ * Apply the static defaults to an ALREADY-BUILT response - the framework's error/404/timeout renders
52
+ * and a handler-returned `Response`, none of which go through the header init below. Defaults, so a
53
+ * name the response already carries is left alone. A guarded `Headers` (a raw `fetch()` result a
54
+ * handler returned) rejects every write, so the first `set` throws with nothing applied and the
55
+ * retry lands on a mutable copy.
56
+ */
57
+ export function applyStaticResponseHeaders(response, statics) {
58
+ const headers = response.headers;
59
+ if (knownMutableHeaders(headers)) {
60
+ applyStaticDefaults(headers, statics);
61
+ return response;
62
+ }
63
+ try {
64
+ applyStaticDefaults(headers, statics);
65
+ }
66
+ catch {
67
+ const clone = new Response(response.body, response);
68
+ applyStaticDefaults(clone.headers, statics);
69
+ return stamped(clone);
70
+ }
71
+ rememberMutableHeaders(headers);
72
+ return response;
73
+ }
74
+ /**
75
+ * Build a JSON response carrying the declared headers, the cheapest way this runtime allows.
76
+ *
77
+ * Everywhere but Deno that is one constructor call with the prebuilt init. Deno charges far more to
78
+ * ingest a header init than to mutate a built response's `Headers` - the same asymmetry the
79
+ * caller-set-headers path above already routes around - and handing it the prebuilt init measured
80
+ * 15% BELOW writing the same headers from a response hook, which would make declaring them a
81
+ * pessimization on that runtime.
82
+ */
83
+ function staticJsonResponse(body, status, statics, contentType, init) {
84
+ if (IS_DENO) {
85
+ return denoResponseWithJsonBody(body, status, statics.record, contentType);
86
+ }
87
+ return new Response(body, init);
88
+ }
89
+ function withStatics(response, statics) {
90
+ return statics === undefined ? response : applyStaticResponseHeaders(response, statics);
91
+ }
92
+ function applyStaticDefaults(headers, statics) {
93
+ for (const [name, value] of statics.entries) {
94
+ if (!headers.has(name))
95
+ headers.set(name, value);
96
+ }
97
+ }
98
+ /** Fold the static defaults under whatever shape the request's own headers took. */
99
+ function withStaticHeaderInit(own, statics) {
100
+ if (own === undefined)
101
+ return statics.record;
102
+ if (own instanceof Headers) {
103
+ // Freshly built by `headersInit` for the cookies case, so mutating it in place is safe.
104
+ applyStaticDefaults(own, statics);
105
+ return own;
106
+ }
107
+ return mergeStaticHeaderRecord(statics.record, own);
108
+ }
109
+ // Deno's Response/Headers implementation ingests a plain header record much more slowly than it
110
+ // mutates an already-created response (the difference is material on realistic middleware routes
111
+ // that add several security/CORS headers). Bun is faster on the record constructor, so keep the
112
+ // portable constructor path there and select the Deno-specific shape only for Web responses that
113
+ // carry a plain record. The first request lazily probes Deno's native JSON content-type so this
114
+ // preserves the runtime's Response.json contract instead of baking in Bun's charset suffix.
115
+ const IS_DENO = typeof globalThis.Deno !== "undefined";
116
+ let denoJsonContentType;
117
+ function responseJsonContentType() {
118
+ if (denoJsonContentType === undefined) {
119
+ denoJsonContentType = Response.json(0).headers.get("content-type") ?? "application/json";
120
+ }
121
+ return denoJsonContentType;
122
+ }
123
+ function denoResponseWithJsonBody(body, status, headers, defaultContentType = responseJsonContentType()) {
124
+ const response = new Response(body, { status });
125
+ let hasContentType = false;
126
+ for (const [name, value] of Object.entries(headers)) {
127
+ response.headers.set(name, value);
128
+ if (name.toLowerCase() === "content-type") {
129
+ hasContentType = true;
130
+ }
131
+ }
132
+ if (!hasContentType)
133
+ response.headers.set("content-type", defaultContentType);
134
+ return response;
135
+ }
136
+ // The framework-buffered-body marker shared with the Node adapter: a Response carrying it exposes
137
+ // its already-serialized bytes without draining. On the Web serving paths it exists ONLY when a
138
+ // registered body/raw hook needs it, so hook-less apps pay nothing.
139
+ const RESPONSE_BODY = Symbol.for("nifra.response.body");
140
+ /**
141
+ * Headers objects the framework itself constructed - guaranteed mutable, no guard. Response
142
+ * middleware adapters consult this before falling back to a mutability probe, so the hot path
143
+ * (every framework-rendered response) never pays per-request `Headers` operations to learn what
144
+ * construction already knew; only a handler-returned foreign `Response` (a raw `fetch()` result,
145
+ * whose headers are guarded immutable) reaches the probe.
146
+ */
147
+ const MUTABLE_RESPONSE_HEADERS = new WeakSet();
148
+ export function knownMutableHeaders(headers) {
149
+ return MUTABLE_RESPONSE_HEADERS.has(headers);
150
+ }
151
+ export function rememberMutableHeaders(headers) {
152
+ MUTABLE_RESPONSE_HEADERS.add(headers);
153
+ }
154
+ /** Stamp a framework-constructed Response's headers as known-mutable, and return it. */
155
+ function stamped(response) {
156
+ MUTABLE_RESPONSE_HEADERS.add(response.headers);
157
+ return response;
158
+ }
159
+ function isBodylessStatus(status) {
160
+ return status === 204 || status === 205 || status === 304;
161
+ }
162
+ /** Normalize handler-produced bodyless responses before response middleware sees them. */
163
+ export function normalizeBodylessResponse(response) {
164
+ if (!isBodylessStatus(response.status))
165
+ return response;
166
+ if (response.body === null && !response.headers.has("content-length"))
167
+ return response;
168
+ const headers = new Headers(response.headers);
169
+ headers.delete("content-length");
170
+ return stamped(new Response(null, {
171
+ status: response.status,
172
+ statusText: response.statusText,
173
+ headers,
174
+ }));
175
+ }
176
+ /** The framework-serialized bytes riding a tagged Response, or `undefined` for raw/streamed ones. */
177
+ export function taggedResponseBody(response, owners) {
178
+ const marker = response[RESPONSE_BODY];
179
+ if (owners !== undefined) {
180
+ // A Web response is framework-buffered only when this app (or an intentionally merged app) put
181
+ // the marker on it. The legacy primitive marker remains readable by the Node bridge, but must
182
+ // not let an arbitrary response impersonate a local framework body on the Web hook path.
183
+ if (typeof marker !== "object" ||
184
+ marker === null ||
185
+ marker instanceof Uint8Array ||
186
+ marker.owner === undefined ||
187
+ !owners.has(marker.owner)) {
188
+ return undefined;
189
+ }
190
+ return marker.body;
191
+ }
192
+ if (typeof marker === "string" || marker instanceof Uint8Array)
193
+ return marker;
194
+ return marker?.body;
195
+ }
196
+ export function taggedResponseOwner(response) {
197
+ const marker = response[RESPONSE_BODY];
198
+ return typeof marker === "object" && marker !== null && "owner" in marker
199
+ ? marker.owner
200
+ : undefined;
201
+ }
202
+ export function markTaggedResponse(response, body, owner) {
203
+ Object.defineProperty(response, RESPONSE_BODY, {
204
+ value: owner === undefined ? body : { body, owner },
205
+ });
206
+ return response;
207
+ }
208
+ function tagged(response, body, tagResponseBody) {
209
+ stamped(response);
210
+ return tagResponseBody === false || tagResponseBody === undefined
211
+ ? response
212
+ : markTaggedResponse(response, body, typeof tagResponseBody === "object" ? tagResponseBody : undefined);
213
+ }
26
214
  /** Fused-lane respond when `c.set` is untouched. Bun 1.3's native `Response.json` now beats the
27
215
  * older hand-inlined stringify + Response construction on this lane while preserving the exact
28
216
  * body/content-type contract; keep the generic fallback for non-JSON values. */
29
- export function fusedRespondNoSet(result) {
217
+ export function fusedRespondNoSet(result, tagResponseBody = false, statics) {
30
218
  if (result !== undefined &&
31
219
  !(result instanceof Response) &&
32
220
  typeof result === "object" &&
33
221
  result !== null &&
34
222
  !isResponseResult(result)) {
35
- return Response.json(result);
223
+ // Deno's cheapest shape for this lane is its own `Response.json` (which fuses serialization and
224
+ // construction natively, and sets the content-type natively) followed by post-construction header
225
+ // writes - NOT a header init, which measured 15% below writing the same names from a hook. So on
226
+ // Deno the tier's only saving here is the response walk itself; every other runtime keeps the
227
+ // one-call prebuilt init below.
228
+ if (statics !== undefined && IS_DENO && !tagResponseBody) {
229
+ const response = Response.json(result);
230
+ for (const [name, value] of statics.entries)
231
+ response.headers.set(name, value);
232
+ return stamped(response);
233
+ }
234
+ // With declared static headers the prebuilt init already carries them plus the JSON
235
+ // content-type, so this lane still constructs the response in one call - the whole point of
236
+ // declaring headers statically instead of writing them per response.
237
+ if (tagResponseBody || statics !== undefined) {
238
+ const body = JSON.stringify(result);
239
+ // Each shape carries the content-type of the lane it stands in for: the framework's own for the
240
+ // tagging path this branch already owned, and `Response.json`'s for the construction below that
241
+ // the static tier replaces. They differ on Deno, and a declared header must not change one.
242
+ if (body !== undefined)
243
+ return tagged(statics === undefined
244
+ ? new Response(body, JSON_INIT_200)
245
+ : tagResponseBody
246
+ ? staticJsonResponse(body, 200, statics, JSON_CONTENT_TYPE, statics.jsonInit200)
247
+ : staticJsonResponse(body, 200, statics, responseJsonContentType(), statics.responseJsonInit200()), body, tagResponseBody);
248
+ }
249
+ return stamped(statics === undefined
250
+ ? Response.json(result)
251
+ : Response.json(result, statics.responseJsonInit200()));
36
252
  }
37
- return toResponse(result, EMPTY_RESPONSE_CONTROLS);
253
+ return toResponse(result, EMPTY_RESPONSE_CONTROLS, tagResponseBody, statics);
38
254
  }
39
255
  /** Fused-lane respond with a context: read `c.set` once; untouched (the common case) -> the fast
40
256
  * JSON respond; touched -> the generic `toResponse` with those controls (statuses, headers, cookies). */
41
- export function fusedRespond(result, ctx) {
257
+ export function fusedRespond(result, ctx, tagResponseBody = false, statics) {
42
258
  const set = ctx[CONTEXT_SET]();
43
259
  if (set === undefined)
44
- return fusedRespondNoSet(result);
45
- return toResponse(result, set);
260
+ return fusedRespondNoSet(result, tagResponseBody, statics);
261
+ return toResponse(result, set, tagResponseBody, statics);
46
262
  }
47
- export function toResponse(result, set) {
263
+ export function toResponse(result, set, tagResponseBody = false, statics) {
48
264
  if (isResponseResult(result)) {
49
- return appendCookiesToResponse(result.toResponse(), set);
265
+ return withStatics(appendCookiesToResponse(normalizeBodylessResponse(result.toResponse()), set), statics);
50
266
  }
51
267
  if (result instanceof Response) {
52
- return appendCookiesToResponse(result, set);
268
+ return withStatics(appendCookiesToResponse(normalizeBodylessResponse(result), set), statics);
53
269
  }
54
- const headers = headersInit(set);
270
+ // The static tier only changes WHICH prebuilt header shape the branches below reach for: the
271
+ // request's own headers are folded on top of the declared defaults once, here.
272
+ const own = headersInit(set);
273
+ const headers = statics === undefined ? own : withStaticHeaderInit(own, statics);
274
+ const jsonCtHeaders = statics === undefined ? JSON_CT_HEADERS : statics.jsonHeaders;
55
275
  const status = set.status ?? (result === undefined ? 204 : 200);
56
- if (headers === undefined && result !== undefined) {
276
+ if (status === 204 || status === 205 || status === 304) {
277
+ return stamped(new Response(null, headers === undefined ? { status } : { status, headers }));
278
+ }
279
+ if (own === undefined && result !== undefined) {
57
280
  // Fast respond (profiled ~50 ns/req faster on every plain-JSON return): `JSON.stringify` + a
58
281
  // prebuilt init beats `Response.json`'s internal init handling. Output is byte-identical -
59
282
  // same body bytes, same probed content-type. `undefined` from stringify (a function/symbol
60
283
  // result) delegates to Response.json so its TypeError contract stays the single source.
61
284
  const body = JSON.stringify(result);
62
285
  if (body !== undefined) {
63
- return new Response(body, status === 200 ? JSON_INIT_200 : { status, headers: JSON_CT_HEADERS });
286
+ const init = status === 200
287
+ ? (statics?.jsonInit200 ?? JSON_INIT_200)
288
+ : { status, headers: jsonCtHeaders };
289
+ return tagged(statics === undefined
290
+ ? new Response(body, init)
291
+ : staticJsonResponse(body, status, statics, JSON_CONTENT_TYPE, init), body, tagResponseBody);
64
292
  }
65
293
  }
66
294
  const init = headers === undefined ? { status } : { status, headers };
67
- return result === undefined ? new Response(null, init) : Response.json(result, init);
295
+ if (result === undefined)
296
+ return stamped(new Response(null, init));
297
+ if (tagResponseBody) {
298
+ const body = JSON.stringify(result);
299
+ if (body !== undefined) {
300
+ const response = IS_DENO && !(headers instanceof Headers)
301
+ ? denoResponseWithJsonBody(body, status, headers, JSON_CT_HEADERS.get("content-type") ?? "application/json;charset=utf-8")
302
+ : new Response(body, { status, headers: withJsonContentType(headers) });
303
+ return tagged(response, body, typeof tagResponseBody === "object" ? tagResponseBody : undefined);
304
+ }
305
+ }
306
+ if (IS_DENO && headers !== undefined && !(headers instanceof Headers)) {
307
+ const body = JSON.stringify(result);
308
+ if (body !== undefined)
309
+ return stamped(denoResponseWithJsonBody(body, status, headers));
310
+ }
311
+ return stamped(Response.json(result, init));
312
+ }
313
+ // Add a JSON content-type without pre-building a `Headers` instance just to check-and-set one key:
314
+ // `new Headers(record)` measured ~8us/call on V8 (Deno) for a handful of header entries - it's a
315
+ // full parse-and-validate of every entry, done here only to ask "is content-type present," when
316
+ // `new Response(body, { headers })` a few lines up already does that same ingestion once, for free,
317
+ // on whatever shape is handed to it. A plain `Record` (the common case - no cookies queued) gets a
318
+ // shallow copy; an existing `Headers` (the cookies case - freshly built by `headersInit`, not
319
+ // exposed elsewhere) is mutated in place, same as before.
320
+ function withJsonContentType(headers) {
321
+ if (headers === undefined)
322
+ return JSON_CT_HEADERS;
323
+ if (headers instanceof Headers) {
324
+ if (!headers.has("content-type"))
325
+ headers.set("content-type", "application/json;charset=utf-8");
326
+ return headers;
327
+ }
328
+ return Object.hasOwn(headers, "content-type")
329
+ ? headers
330
+ : { ...headers, "content-type": "application/json;charset=utf-8" };
68
331
  }
69
332
  export function appendCookiesToResponse(response, set) {
70
333
  // A handler may queue cookies (`c.set.cookie` - e.g. a session cookie) AND return its own Response
@@ -1 +1 @@
1
- {"version":3,"file":"respond.js","sourceRoot":"","sources":["../../src/server/respond.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,EACX,uBAAuB,EAEvB,gBAAgB,GACjB,MAAM,mBAAmB,CAAA;AAG1B;;oGAEoG;AACpG,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAA;IAC5B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACtE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACzC,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAClE,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,iGAAiG;AACjG,+FAA+F;AAC/F,sFAAsF;AACtF,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC;IAClC,cAAc,EAAE,gCAAgC;CACjD,CAAC,CAAA;AACF,MAAM,aAAa,GAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAA;AAE7E;;gFAEgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,IACE,MAAM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C,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC;QAC3C,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,gCAAgC,EAAE,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAkB,EAAE,GAAW;IACrE,mGAAmG;IACnG,2FAA2F;IAC3F,oGAAoG;IACpG,+EAA+E;IAC/E,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAA;IAC5B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -29,6 +29,17 @@
29
29
  * That is not an inconsistency to paper over: a strict schema has already declared that extra fields
30
30
  * are an error, and a stripping one has declared they are ignorable. Enforcement honours what the
31
31
  * author wrote rather than overriding it.
32
+ *
33
+ * ## What enforcement costs
34
+ *
35
+ * Less than it looks like it should. With a compiled validator (`@nifrajs/schema`'s `t` compiles at
36
+ * construction; zod/valibot equivalents are similarly cheap), the check itself measures in the
37
+ * ~100ns-per-response range - on a realistic middleware-carrying route, enforce mode benchmarks
38
+ * within measurement noise of the same route with no contract at all, on Bun and Node alike. The
39
+ * one real cost is structural: a contracted route cannot take the bare-route fused lane, because
40
+ * the check needs the handler's VALUE before it becomes bytes. A route with any middleware, derive,
41
+ * or lifecycle hook has already left that lane, so for the routes that look like production the
42
+ * contract is effectively free - declare it.
32
43
  */
33
44
  import type { StandardSchemaV1 } from "../schema/standard.js";
34
45
  import type { IdentityPlugin } from "./plugin.js";
@@ -83,9 +94,12 @@ export interface ResponseContractRuntime {
83
94
  * Install it before the routes it should cover - like `idempotency()`, the decision is made per route
84
95
  * at registration, so routes registered earlier are not retroactively covered.
85
96
  *
86
- * A contracted route leaves the fused and native fast paths, because the check needs the handler's
87
- * value before it becomes bytes. That is the same trade an idempotent route makes, and the reason this
88
- * is opt-in rather than always on.
97
+ * The check itself is cheap - with a compiled validator it measures in the ~100ns-per-response
98
+ * range, within benchmark noise of an uncontracted route on any route that carries middleware or a
99
+ * derive. What a contracted route does give up is the bare-route fused lane (the check needs the
100
+ * handler's value before it becomes bytes), which only a route with NO other lifecycle steps was
101
+ * taking anyway. Opt-in because not installing the plugin keeps the lane out of the bundle, not
102
+ * because enforcement is expensive.
89
103
  */
90
104
  export declare function responseContract(mode?: ResponseContractMode): IdentityPlugin;
91
105
  //# sourceMappingURL=response-contract-lane.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"response-contract-lane.d.ts","sourceRoot":"","sources":["../../src/server/response-contract-lane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAA;AAErD,uFAAuF;AACvF,MAAM,MAAM,uBAAuB;AACjC,yGAAyG;AACvG;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE;AAClD,gGAAgG;GAC9F;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC9E,kGAAkG;GAChG;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AA0B5D;;;;;GAKG;AACH,wBAAgB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;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAQ5D;AA0BD;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAA;IACnC,KAAK,CACH,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,OAAO,GACd,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;CAC9D;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,oBAA6B,GAAG,cAAc,CAUpF"}
@@ -62,9 +62,12 @@ function interpret(settled, result, mode) {
62
62
  * Install it before the routes it should cover - like `idempotency()`, the decision is made per route
63
63
  * at registration, so routes registered earlier are not retroactively covered.
64
64
  *
65
- * A contracted route leaves the fused and native fast paths, because the check needs the handler's
66
- * value before it becomes bytes. That is the same trade an idempotent route makes, and the reason this
67
- * is opt-in rather than always on.
65
+ * The check itself is cheap - with a compiled validator it measures in the ~100ns-per-response
66
+ * range, within benchmark noise of an uncontracted route on any route that carries middleware or a
67
+ * derive. What a contracted route does give up is the bare-route fused lane (the check needs the
68
+ * handler's value before it becomes bytes), which only a route with NO other lifecycle steps was
69
+ * taking anyway. Opt-in because not installing the plugin keeps the lane out of the bundle, not
70
+ * because enforcement is expensive.
68
71
  */
69
72
  export function responseContract(mode = "warn") {
70
73
  const runtime = {
@@ -1 +1 @@
1
- {"version":3,"file":"response-contract-lane.js","sourceRoot":"","sources":["../../src/server/response-contract-lane.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAwBxD,MAAM,aAAa,GAAG,CAAC,CAAU,EAAgC,EAAE,CACjE,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAA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/router.js";
9
9
  import type { ClientIpTrust } from "./client-ip.js";
10
10
  import type { Context, Platform, RouteSchema } from "./context.js";
11
11
  import type { Logger } from "./logger.js";
12
+ import type { NodeRequestHook, NodeResponseHook, ResponseBodyHook, ResponseHeadersHook } from "./node-outcome-hook.js";
12
13
  import type { MaybePromise, OnRequestResult } from "./server.js";
13
14
  /**
14
15
  * The outcome of a capacity-admission decision. `admitted` requests carry a `release` the server calls
@@ -186,10 +187,46 @@ export interface RunningServer {
186
187
  export interface Middleware {
187
188
  readonly name?: string;
188
189
  readonly onRequest?: (req: Request, platform?: Platform) => MaybePromise<OnRequestResult>;
190
+ /** Allocation-light Node equivalent of `onRequest` for header-only hooks. */
191
+ readonly onNodeRequest?: NodeRequestHook;
189
192
  readonly around?: <T>(context: Context, next: () => MaybePromise<T>) => MaybePromise<T>;
190
193
  readonly beforeHandle?: (context: Context) => MaybePromise<unknown>;
191
194
  readonly afterHandle?: (result: unknown, context: Context) => MaybePromise<unknown>;
192
195
  readonly onResponse?: (response: Response, req: Request) => MaybePromise<Response>;
196
+ /**
197
+ * Header-only equivalent of `onResponse` for the Node-direct serializer. It is used only when every
198
+ * response hook in the app supplies this paired native implementation; arbitrary response transforms
199
+ * continue through the Web Response path.
200
+ */
201
+ readonly onNodeResponse?: NodeResponseHook;
202
+ /**
203
+ * Response headers with NO per-request decision behind them. Declared here instead of written by a
204
+ * hook, they are folded into response construction, so a bundle that only sets static headers does
205
+ * not cost the app its fused/native lanes (see {@link Server.responseHeaders}). They are defaults:
206
+ * anything the request produced wins. Reach for `onResponseHeaders` the moment a value depends on
207
+ * the request, the route, or the response.
208
+ */
209
+ readonly responseHeaders?: Readonly<Record<string, string>>;
210
+ /**
211
+ * PORTABLE header-only response hook - the recommended shape when the middleware only reads or
212
+ * writes headers. One implementation runs on every runtime: inside the Web `onResponse` walk
213
+ * against the response's own `Headers`, and on Node as a self-paired native hook against the
214
+ * outcome record - so it never forces the Node adapter off its direct writer. Use `onResponse` +
215
+ * an optional `onNodeResponse` twin only when the hook must see a real `Response`.
216
+ */
217
+ readonly onResponseHeaders?: ResponseHeadersHook;
218
+ /**
219
+ * PORTABLE post-serialization body hook - the payload tier. Receives the final
220
+ * framework-serialized bytes (already resident on every runtime; no stream is drained) plus the
221
+ * header view and status, and may return replacement bytes. Raw handler-returned `Response`s
222
+ * (proxies, SSE, streamed SSR) are skipped by contract - transforming those needs `onResponse`.
223
+ */
224
+ readonly onResponseBody?: ResponseBodyHook;
225
+ /**
226
+ * Response transform for untagged/raw responses (streams, proxied fetches, and framework errors).
227
+ * Framework-serialized payloads use `onResponseBody` and remain on the Node direct lane.
228
+ */
229
+ readonly onResponseRaw?: (response: Response, req: Request) => MaybePromise<Response>;
193
230
  readonly onResponseFinalized?: (outcome: ResponseFinalization, req: Request) => MaybePromise<void>;
194
231
  readonly onError?: (error: unknown, context: Context) => MaybePromise<unknown>;
195
232
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server-types.d.ts","sourceRoot":"","sources":["../../src/server/server-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEhE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,OAAO,IAAI,IAAI,CAAA;CAAE,GAC5C;IAA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