@nifrajs/core 5.12.0 → 5.12.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nifrajs/core",
3
- "version": "5.12.0",
3
+ "version": "5.12.1",
4
4
  "description": "Bun-native, contract-first HTTP framework - the router, server, and route descriptor.",
5
5
  "keywords": [
6
6
  "bun",
package/src/index.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * read its own package.json at runtime. `scripts/version.ts` rewrites it on every release bump and
17
17
  * `check:publish` asserts it equals `@nifrajs/core`'s package version.
18
18
  */
19
- export const VERSION = "5.12.0" as const
19
+ export const VERSION = "5.12.1" as const
20
20
 
21
21
  export type Version = typeof VERSION
22
22
 
@@ -26,7 +26,7 @@ if (!copies.includes(here) && copies.push(here) > 1) {
26
26
 
27
27
  /** This copy's version: a literal like the package root's `VERSION` (no fs on the edge), which
28
28
  * `scripts/version.ts` rewrites on every release and `check:publish` asserts. */
29
- const COPY_VERSION = "5.12.0"
29
+ const COPY_VERSION = "5.12.1"
30
30
 
31
31
  /** Record this copy's version beside its URL. Called by each `server()` behind the development guard,
32
32
  * so a production bundle drops it with the version; a copy that built a server has recorded one. */
@@ -5,7 +5,7 @@
5
5
  * sits below the server module in the graph.
6
6
  */
7
7
  import type { RequestBudget } from "../budget.ts"
8
- import { markResidentBody } from "../mount.ts"
8
+ import { markResidentBody, residentBodiesRecorded } from "../mount.ts"
9
9
  import { applyTransportCap, readBoundedBytes } from "./body.ts"
10
10
  import { readBoundedJsonSource } from "./body-lane.ts"
11
11
  import type { Platform } from "./context.ts"
@@ -165,6 +165,8 @@ function responseTextContentType(): string {
165
165
  /** `c.text`'s own default, unchanged: the explicit one nifra has always declared when the caller
166
166
  * passes no headers of their own. */
167
167
  const TEXT_CONTENT_TYPE = "text/plain; charset=utf-8"
168
+ const TEXT_RESPONSE_HEADERS = { "content-type": TEXT_CONTENT_TYPE }
169
+ const TEXT_RESPONSE_INIT: ResponseInit = { headers: TEXT_RESPONSE_HEADERS }
168
170
 
169
171
  /** Where a serving adapter that shares one platform across requests leaves its socket-peer lookup.
170
172
  * `c.clientIp` calls it with the request when a handler reads the address, so a request whose
@@ -439,13 +441,15 @@ export class RequestContext implements RawContext {
439
441
  }
440
442
  }
441
443
  // Default to text/plain; if the caller passes their own headers, they own the content-type.
442
- if (i?.headers !== undefined) return markResidentBody(residentText(new Response(body, i), body))
443
- return markResidentBody(
444
- residentText(
445
- new Response(body, { ...i, headers: { "content-type": TEXT_CONTENT_TYPE } }),
446
- body,
447
- ),
448
- )
444
+ const response =
445
+ i?.headers !== undefined
446
+ ? new Response(body, i)
447
+ : new Response(
448
+ body,
449
+ i === undefined ? TEXT_RESPONSE_INIT : { ...i, headers: TEXT_RESPONSE_HEADERS },
450
+ )
451
+ const resident = residentText(response, body)
452
+ return residentBodiesRecorded ? markResidentBody(resident) : resident
449
453
  }
450
454
 
451
455
  get query(): unknown {
@@ -613,6 +613,17 @@ export function fusedRespond(
613
613
  unstamped = false,
614
614
  ): Response {
615
615
  const set = ctx[CONTEXT_SET]()
616
+ if (
617
+ set === undefined &&
618
+ statics === undefined &&
619
+ !tagResponseBody &&
620
+ result instanceof Response &&
621
+ !isResponseResult(result) &&
622
+ !responseBodyUsed(result)
623
+ ) {
624
+ if (!isBodylessStatus(result.status)) return result
625
+ return normalizeBodylessResponse(result, unstamped ? undefined : ctx[CONTEXT_REQUEST])
626
+ }
616
627
  const request = unstamped ? undefined : ctx[CONTEXT_REQUEST]
617
628
  if (set === undefined)
618
629
  return fusedRespondNoSet(result, tagResponseBody, statics, unstamped, request)
@@ -7599,7 +7599,7 @@ export class Server<R extends Registry = EmptyRegistry, Ctx = EmptyContext, Hook
7599
7599
  if (
7600
7600
  mayUseStaticResponse &&
7601
7601
  staticResponse !== undefined &&
7602
- (method === "GET" || method === "HEAD") &&
7602
+ (method === "GET" || method === "HEAD" || method === "POST") &&
7603
7603
  // Bun 1.3 can misframe null-body status codes in its native static table.
7604
7604
  staticResponse.status !== 204 &&
7605
7605
  staticResponse.status !== 205 &&