Skip to content

NextRush v4.2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 10 Nov 20:41
· 888 commits to 66d0c122be0889299f659a435876070d861811ce since this release

NextRush v4.2.0

Highlights

  • handle() now returns a callable handler set, so a route module can assign each method directly instead of destructuring one call. Repeated calls with the same app source and equivalent options share one initialized engine.
  • handle() returns NextRouteHandlerSet — a function that also carries GET…OPTIONS as properties. All seven names are the same dispatcher reference.
  • Handler sets are cached per app source in a WeakMap, matched on timeout value and onError identity. A different timeout or error handler gets its own set and engine.
  • The cache is weakly keyed, so a discarded app (including a route-module reload under HMR) does not leak its engine.
  • A failed boot still retries on the next request; the failure is not cached permanently.
  • Destructuring is unchanged and remains the recommended single-call form.
  • feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)
  • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
  • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
  • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
  • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.

Packages

Package Version
nextrush 4.2.0
@nextrush/adapter-bun 1.2.0
@nextrush/adapter-deno 1.2.0
@nextrush/adapter-edge 1.1.1
@nextrush/adapter-nextjs 1.2.0
@nextrush/adapter-node 4.2.0
@nextrush/adapter-serverless 1.2.0
@nextrush/class 1.0.4
@nextrush/core 4.2.0
@nextrush/dev 1.1.4
@nextrush/di 4.2.0
@nextrush/errors 4.2.0
@nextrush/openapi 1.0.5
@nextrush/router 4.2.0
@nextrush/runtime 4.2.0
@nextrush/stream 1.0.4
@nextrush/testing 1.0.4
@nextrush/types 4.2.0
@nextrush/validation 1.1.0

Changes

nextrush

Minor Changes

  • #78 d3cfdbf Thanks @0xTanzim! - handle() now returns a callable handler set, so a route module can assign each method directly
    instead of destructuring one call. Repeated calls with the same app source and equivalent options
    share one initialized engine.

    // app/api/[[...route]]/route.ts
    export const { GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS } = handle(app); // unchanged
    
    // or, one export per method — still one engine
    export const GET = handle(app);
    export const POST = handle(app);
    • handle() returns NextRouteHandlerSet — a function that also carries GET…OPTIONS as
      properties. All seven names are the same dispatcher reference.
    • Handler sets are cached per app source in a WeakMap, matched on timeout value and onError
      identity. A different timeout or error handler gets its own set and engine.
    • The cache is weakly keyed, so a discarded app (including a route-module reload under HMR) does
      not leak its engine.
    • A failed boot still retries on the next request; the failure is not cached permanently.
    • Destructuring is unchanged and remains the recommended single-call form.

    NextRouteHandlerSet is also re-exported from nextrush/nextjs.

  • #80 bd568d8 Thanks @0xTanzim! - feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)

    • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
    • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
    • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
    • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.

Patch Changes

  • Updated dependencies [914f2de, bd568d8, 4bb3dbf, 73fd473]:
    • @nextrush/types@4.2.0
    • @nextrush/adapter-node@4.2.0
    • @nextrush/core@4.2.0
    • @nextrush/router@4.2.0
    • @nextrush/errors@4.2.0

@nextrush/adapter-bun

Minor Changes

  • #80 4e0169a Thanks @0xTanzim! - Hardens Bun and Deno adapters against runtime mismatches, eliminates mandatory second dummy server arguments, and exports runtime checking utilities (#72, #77).

    What's new

    • Defensive Runtime Guarding: Calling serve(app) in @nextrush/adapter-bun or @nextrush/adapter-deno outside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without "bunVersion") throws a descriptive ServerStartError with code 'ERR_RUNTIME_NOT_DETECTED' and actionable migration guidance rather than crashing with an unhandled ReferenceError: Bun is not defined or ReferenceError: Deno is not defined.
    • Optional Server / Info Parameter: createHandler(app) in @nextrush/adapter-bun and @nextrush/adapter-deno now marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct calling await handler(request) without supplying dummy mock server or connection info objects.
    • Exported Runtime Detection: Both @nextrush/adapter-bun and @nextrush/adapter-deno re-export isBun / isDeno (and isBunRuntime / isDenoRuntime) and ServerStartError for straightforward runtime inspection.
    • Runtime Error Hierarchy: Adds 'ERR_RUNTIME_NOT_DETECTED' to ServerStartErrorCode in @nextrush/runtime.

Patch Changes

@nextrush/adapter-deno

Minor Changes

  • #80 4e0169a Thanks @0xTanzim! - Hardens Bun and Deno adapters against runtime mismatches, eliminates mandatory second dummy server arguments, and exports runtime checking utilities (#72, #77).

    What's new

    • Defensive Runtime Guarding: Calling serve(app) in @nextrush/adapter-bun or @nextrush/adapter-deno outside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without "bunVersion") throws a descriptive ServerStartError with code 'ERR_RUNTIME_NOT_DETECTED' and actionable migration guidance rather than crashing with an unhandled ReferenceError: Bun is not defined or ReferenceError: Deno is not defined.
    • Optional Server / Info Parameter: createHandler(app) in @nextrush/adapter-bun and @nextrush/adapter-deno now marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct calling await handler(request) without supplying dummy mock server or connection info objects.
    • Exported Runtime Detection: Both @nextrush/adapter-bun and @nextrush/adapter-deno re-export isBun / isDeno (and isBunRuntime / isDenoRuntime) and ServerStartError for straightforward runtime inspection.
    • Runtime Error Hierarchy: Adds 'ERR_RUNTIME_NOT_DETECTED' to ServerStartErrorCode in @nextrush/runtime.

Patch Changes

@nextrush/adapter-edge

Patch Changes

  • #80 d87f80e Thanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging

    • AWS Lambda & ALB Hardening: Injected statusDescription and broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer in Promise.race; added unhandled rejection shield on tracked tasks; set callbackWaitsForEmptyEventLoop = false.
    • Azure Functions v4 & GCF: Added RFC-compliant Set-Cookie parsing (Domain, Path, Expires, Max-Age, Secure, HttpOnly, SameSite) for Azure Functions v4 structured cookies; wrapped GCF handlers in top-level error boundaries.
    • Base64 Body Parsing: Added null and empty string guards before base64 body decoding to prevent atob("null") ghost bytes in API Gateway v2 and GCF mappers.
    • Streaming Cancellation & Abort Safety: Added controller.onCancel() to StreamController and guarded enqueue() against client disconnects so consumer stream cancellation safely swallows StreamAbortedError without throwing unhandled TypeError exceptions.
    • Packaging Dual-Entry Bridge: Exported import * as _mod from './index.js'; export * from './index.js'; export default _mod.default; in serverless artifacts to support both named handler exports (export const handler = ...) and default exports without link-time syntax errors.
    • Cold-Start Boot Gate: Memoized application boot with error resets in Cloudflare Workers and Vercel Edge handlers to eliminate initialization stampedes.
  • Updated dependencies [4e0169a, 914f2de, d87f80e, bd568d8, 4bb3dbf, 73fd473]:

    • @nextrush/runtime@4.2.0
    • @nextrush/types@4.2.0
    • @nextrush/stream@1.0.4
    • @nextrush/core@4.2.0
    • @nextrush/errors@4.2.0

@nextrush/adapter-nextjs

Minor Changes

  • #78 d3cfdbf Thanks @0xTanzim! - handle() now returns a callable handler set, so a route module can assign each method directly
    instead of destructuring one call. Repeated calls with the same app source and equivalent options
    share one initialized engine.

    // app/api/[[...route]]/route.ts
    export const { GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS } = handle(app); // unchanged
    
    // or, one export per method — still one engine
    export const GET = handle(app);
    export const POST = handle(app);
    • handle() returns NextRouteHandlerSet — a function that also carries GET…OPTIONS as
      properties. All seven names are the same dispatcher reference.
    • Handler sets are cached per app source in a WeakMap, matched on timeout value and onError
      identity. A different timeout or error handler gets its own set and engine.
    • The cache is weakly keyed, so a discarded app (including a route-module reload under HMR) does
      not leak its engine.
    • A failed boot still retries on the next request; the failure is not cached permanently.
    • Destructuring is unchanged and remains the recommended single-call form.

    NextRouteHandlerSet is also re-exported from nextrush/nextjs.

Patch Changes

@nextrush/adapter-node

Minor Changes

  • #78 914f2de Thanks @0xTanzim! - ctx.json(), ctx.html() and ctx.send() accept a second argument: a numeric status or a
    ResponseOptions object.

    ctx.json({ users }); // unchanged
    ctx.json({ id: 'u_123' }, 201);
    ctx.json({ id: 'u_123' }, { status: 201, headers: { Location: '/users/u_123' } });
    • An explicit status overrides the carried ctx.status for that response and is recorded back onto
      it, so post-handler middleware (logging, metrics) sees the status that was actually sent.
    • Accepted statuses are integers 200-599; anything else throws a RangeError before the response is
      committed.
    • Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
      Set-Cookie accumulates, an array replaces then appends, and a supplied Content-Type wins over
      the helper's automatic media type. Content-Length is derived from the body and is rejected.
    • ctx.status = code is unchanged and remains supported.

    Behavior fix included: an explicitly recorded Content-Type now wins over a body method's default
    media type in both orders, which is the behavior the adapter contract already documented.

Patch Changes

@nextrush/adapter-serverless

Minor Changes

  • #80 73fd473 Thanks @0xTanzim! - Adds first-class createVercelHandler for Node.js Serverless runtime on Vercel (Fluid Compute) and hybrid standalone runner support (#71).

    What's new

    • Universal Dual-Protocol Dispatch: createVercelHandler(app, options?) returns a callable handler set accepting both Web standard Request (Route Handlers) and Node.js (IncomingMessage, ServerResponse) invocations.
    • Node.js HTTP Bridge: Efficiently adapts Node incoming messages into Web standard Request without external dependencies, and streams the Web Response with chunk backpressure (drain), multi-cookie preservation via response.headers.getSetCookie(), and client disconnect cancellation (reader.cancel()).
    • Callable Handler Set: The returned handler carries named HTTP method exports (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, fetch) and .listenIfStandalone(), supporting both universal default export and named destructuring.
    • Standalone Runner Support: listenIfStandalone(handler, options?), isServerlessEnvironment(), and isStandaloneEnvironment() enable running the identical handler in local dev, Docker, or standalone VMs without wrapping code in environment guards.
    • Platform Identity: Adds 'vercel' to PlatformId, declared on ctx.platform === 'vercel'.

Patch Changes

  • #80 d87f80e Thanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging

    • AWS Lambda & ALB Hardening: Injected statusDescription and broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer in Promise.race; added unhandled rejection shield on tracked tasks; set callbackWaitsForEmptyEventLoop = false.
    • Azure Functions v4 & GCF: Added RFC-compliant Set-Cookie parsing (Domain, Path, Expires, Max-Age, Secure, HttpOnly, SameSite) for Azure Functions v4 structured cookies; wrapped GCF handlers in top-level error boundaries.
    • Base64 Body Parsing: Added null and empty string guards before base64 body decoding to prevent atob("null") ghost bytes in API Gateway v2 and GCF mappers.
    • Streaming Cancellation & Abort Safety: Added controller.onCancel() to StreamController and guarded enqueue() against client disconnects so consumer stream cancellation safely swallows StreamAbortedError without throwing unhandled TypeError exceptions.
    • Packaging Dual-Entry Bridge: Exported import * as _mod from './index.js'; export * from './index.js'; export default _mod.default; in serverless artifacts to support both named handler exports (export const handler = ...) and default exports without link-time syntax errors.
    • Cold-Start Boot Gate: Memoized application boot with error resets in Cloudflare Workers and Vercel Edge handlers to eliminate initialization stampedes.
  • Updated dependencies [4e0169a, 914f2de, d87f80e, bd568d8, 4bb3dbf, 73fd473]:

    • @nextrush/runtime@4.2.0
    • @nextrush/types@4.2.0
    • @nextrush/adapter-edge@1.1.1
    • @nextrush/stream@1.0.4
    • @nextrush/core@4.2.0
    • @nextrush/errors@4.2.0

@nextrush/class

Patch Changes

  • Updated dependencies [914f2de, bd568d8, 4bb3dbf, 73fd473]:
    • @nextrush/types@4.2.0
    • @nextrush/core@4.2.0
    • @nextrush/router@4.2.0
    • @nextrush/errors@4.2.0
    • @nextrush/di@4.2.0

@nextrush/core

Minor Changes

  • #80 bd568d8 Thanks @0xTanzim! - feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)

    • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
    • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
    • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
    • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.

Patch Changes

@nextrush/dev

Patch Changes

  • #80 d87f80e Thanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging

    • AWS Lambda & ALB Hardening: Injected statusDescription and broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer in Promise.race; added unhandled rejection shield on tracked tasks; set callbackWaitsForEmptyEventLoop = false.
    • Azure Functions v4 & GCF: Added RFC-compliant Set-Cookie parsing (Domain, Path, Expires, Max-Age, Secure, HttpOnly, SameSite) for Azure Functions v4 structured cookies; wrapped GCF handlers in top-level error boundaries.
    • Base64 Body Parsing: Added null and empty string guards before base64 body decoding to prevent atob("null") ghost bytes in API Gateway v2 and GCF mappers.
    • Streaming Cancellation & Abort Safety: Added controller.onCancel() to StreamController and guarded enqueue() against client disconnects so consumer stream cancellation safely swallows StreamAbortedError without throwing unhandled TypeError exceptions.
    • Packaging Dual-Entry Bridge: Exported import * as _mod from './index.js'; export * from './index.js'; export default _mod.default; in serverless artifacts to support both named handler exports (export const handler = ...) and default exports without link-time syntax errors.
    • Cold-Start Boot Gate: Memoized application boot with error resets in Cloudflare Workers and Vercel Edge handlers to eliminate initialization stampedes.

@nextrush/di

Patch Changes

@nextrush/errors

Minor Changes

  • #78 4bb3dbf Thanks @0xTanzim! - validate() exposes coerced query/params and accepts a failure status.

    const Query = z.object({ limit: z.coerce.number().int().min(1).default(50) });
    
    app.get('/items', validate({ query: Query }, { errorStatus: 422 }), (ctx) => {
      const { query } = validated(ctx); // { limit: number } — coerced
      ctx.json({ limit: query.limit });
    });
    • Coerced query/params are no longer discarded. They are written to ctx.state.validated and
      read back with the new validated(ctx) accessor, which returns {} when no validate() ran so a
      destructure never throws. Only targets that were configured and passed appear. Nothing is written
      on failure, so the existing atomicity guarantee holds.

    • Strict type safety and helpers. validated is fully generic (validated<{ query: MyQuery }>(ctx))
      and provides target-specific helpers (validated.query<T>(ctx), validated.params<T>(ctx), validated.body<T>(ctx))
      for cast-free typing under TypeScript strict mode.

    • ctx.query and ctx.params are still left unmodified. They are declared as string maps, so writing
      a coerced number back would make the type disagree with the runtime. The coerced values live on
      ctx.state (which is unknown-valued) instead.

    • createValidate() factory. For projects where an API specification mandates 422 (or any custom status)
      across dozens of routers, createValidate({ errorStatus: 422 }) creates a preconfigured validate function
      so the status option does not need to be repeated on every route.

    • ValidationError accepts an optional status, defaulting to 400, so new ValidationError(issues)
      is unchanged for every existing caller. validate(arg, { errorStatus }) threads it through.
      ValidationError.fromField and fromFields also accept optional status.

    • errorHandler({ validationErrorStatus: 422 }) provides a global fallback in @nextrush/errors
      mapping default 400 validation errors to 422.

    • The error code stays VALIDATION_ERROR at any status: the code names the kind of failure, the
      status names its class. A 422 validation failure still aggregates every issue across every target.

    • errorStatus is validated at construction and must be an integer 400-499, so a typo throws a
      RangeError at startup instead of producing an invalid status at request time. Without this guard an
      out-of-range value reached res.writeHead(), whose asynchronous ERR_HTTP_INVALID_STATUS_CODE is an
      uncaught exception that takes the whole process down — a config typo became a remote DoS.

    • Stacking validate() on one route merges the coerced targets instead of the second call
      clobbering the first, so validate({ params }) then validate({ query }) keeps both.

    • A body schema without a body parser now names the real cause. Previously a request that carried
      a body but had no parser installed failed with "expected object, received undefined", which blames the
      schema. It now throws an error naming the missing bodyParser(); the client still receives an opaque
      5xx and the developer gets the cause in the log.

    • A misspelled or unknown schema target is rejected at construction. validate({ querys: Schema })
      used to validate nothing and silently pass every request through — the worst failure mode for a
      validation middleware, because it looks like it works. Unknown keys, and targets whose value is not a
      Standard Schema, now throw a TypeError naming the offending key. An empty map stays a documented
      pass-through.

Patch Changes

@nextrush/openapi

Patch Changes

@nextrush/router

Minor Changes

  • #80 bd568d8 Thanks @0xTanzim! - feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)

    • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
    • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
    • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
    • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.

Patch Changes

@nextrush/runtime

Minor Changes

  • #80 4e0169a Thanks @0xTanzim! - Hardens Bun and Deno adapters against runtime mismatches, eliminates mandatory second dummy server arguments, and exports runtime checking utilities (#72, #77).

    What's new

    • Defensive Runtime Guarding: Calling serve(app) in @nextrush/adapter-bun or @nextrush/adapter-deno outside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without "bunVersion") throws a descriptive ServerStartError with code 'ERR_RUNTIME_NOT_DETECTED' and actionable migration guidance rather than crashing with an unhandled ReferenceError: Bun is not defined or ReferenceError: Deno is not defined.
    • Optional Server / Info Parameter: createHandler(app) in @nextrush/adapter-bun and @nextrush/adapter-deno now marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct calling await handler(request) without supplying dummy mock server or connection info objects.
    • Exported Runtime Detection: Both @nextrush/adapter-bun and @nextrush/adapter-deno re-export isBun / isDeno (and isBunRuntime / isDenoRuntime) and ServerStartError for straightforward runtime inspection.
    • Runtime Error Hierarchy: Adds 'ERR_RUNTIME_NOT_DETECTED' to ServerStartErrorCode in @nextrush/runtime.
  • #78 914f2de Thanks @0xTanzim! - ctx.json(), ctx.html() and ctx.send() accept a second argument: a numeric status or a
    ResponseOptions object.

    ctx.json({ users }); // unchanged
    ctx.json({ id: 'u_123' }, 201);
    ctx.json({ id: 'u_123' }, { status: 201, headers: { Location: '/users/u_123' } });
    • An explicit status overrides the carried ctx.status for that response and is recorded back onto
      it, so post-handler middleware (logging, metrics) sees the status that was actually sent.
    • Accepted statuses are integers 200-599; anything else throws a RangeError before the response is
      committed.
    • Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
      Set-Cookie accumulates, an array replaces then appends, and a supplied Content-Type wins over
      the helper's automatic media type. Content-Length is derived from the body and is rejected.
    • ctx.status = code is unchanged and remains supported.

    Behavior fix included: an explicitly recorded Content-Type now wins over a body method's default
    media type in both orders, which is the behavior the adapter contract already documented.

  • #80 bd568d8 Thanks @0xTanzim! - feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)

    • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
    • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
    • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
    • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.

Patch Changes

@nextrush/stream

Patch Changes

  • #80 d87f80e Thanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging

    • AWS Lambda & ALB Hardening: Injected statusDescription and broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer in Promise.race; added unhandled rejection shield on tracked tasks; set callbackWaitsForEmptyEventLoop = false.
    • Azure Functions v4 & GCF: Added RFC-compliant Set-Cookie parsing (Domain, Path, Expires, Max-Age, Secure, HttpOnly, SameSite) for Azure Functions v4 structured cookies; wrapped GCF handlers in top-level error boundaries.
    • Base64 Body Parsing: Added null and empty string guards before base64 body decoding to prevent atob("null") ghost bytes in API Gateway v2 and GCF mappers.
    • Streaming Cancellation & Abort Safety: Added controller.onCancel() to StreamController and guarded enqueue() against client disconnects so consumer stream cancellation safely swallows StreamAbortedError without throwing unhandled TypeError exceptions.
    • Packaging Dual-Entry Bridge: Exported import * as _mod from './index.js'; export * from './index.js'; export default _mod.default; in serverless artifacts to support both named handler exports (export const handler = ...) and default exports without link-time syntax errors.
    • Cold-Start Boot Gate: Memoized application boot with error resets in Cloudflare Workers and Vercel Edge handlers to eliminate initialization stampedes.
  • Updated dependencies [914f2de, bd568d8, 73fd473]:

    • @nextrush/types@4.2.0

@nextrush/testing

Patch Changes

  • Updated dependencies [914f2de, bd568d8, 73fd473]:
    • @nextrush/types@4.2.0
    • @nextrush/core@4.2.0
    • @nextrush/router@4.2.0
    • @nextrush/class@1.0.4
    • @nextrush/di@4.2.0

@nextrush/types

Minor Changes

  • #78 914f2de Thanks @0xTanzim! - ctx.json(), ctx.html() and ctx.send() accept a second argument: a numeric status or a
    ResponseOptions object.

    ctx.json({ users }); // unchanged
    ctx.json({ id: 'u_123' }, 201);
    ctx.json({ id: 'u_123' }, { status: 201, headers: { Location: '/users/u_123' } });
    • An explicit status overrides the carried ctx.status for that response and is recorded back onto
      it, so post-handler middleware (logging, metrics) sees the status that was actually sent.
    • Accepted statuses are integers 200-599; anything else throws a RangeError before the response is
      committed.
    • Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
      Set-Cookie accumulates, an array replaces then appends, and a supplied Content-Type wins over
      the helper's automatic media type. Content-Length is derived from the body and is rejected.
    • ctx.status = code is unchanged and remains supported.

    Behavior fix included: an explicitly recorded Content-Type now wins over a body method's default
    media type in both orders, which is the behavior the adapter contract already documented.

  • #80 bd568d8 Thanks @0xTanzim! - feat(core,runtime,router): add universal fetch (app.fetch) and multi-prefix mounting (#74, #77)

    • Universal Fetch (app.fetch): Instance-bound Web standards request handler on Application enabling direct zero-boilerplate export (export default app; / export default { fetch: app.fetch }) across Bun, Cloudflare Workers, Vercel Edge, Deno, and Web standard fetch unit tests without manual adapter imports.
    • Multi-Runtime Signature Normalization: UniversalWebContext transparently normalizes 5 runtime signatures (1-arg fetch(req), Cloudflare Workers (req, env, ctx) with ctx.env and ctx.waitUntil, Vercel Edge (req, ctx) with ctx.waitUntil, Bun (req, server) with server.requestIP, and Deno (req, info) with info.remoteAddr).
    • Zero Overhead on Traditional Servers: Lazily initialized fetch runner ensures Node.js listen(app, port) servers incur zero allocations, zero CPU overhead, and zero timer scheduling.
    • Multi-Prefix Router Mounting: app.route(prefixes, router) and router.mount(prefixes, subRouter) accept arrays of path prefixes (e.g. ['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
  • #80 73fd473 Thanks @0xTanzim! - Adds first-class createVercelHandler for Node.js Serverless runtime on Vercel (Fluid Compute) and hybrid standalone runner support (#71).

    What's new

    • Universal Dual-Protocol Dispatch: createVercelHandler(app, options?) returns a callable handler set accepting both Web standard Request (Route Handlers) and Node.js (IncomingMessage, ServerResponse) invocations.
    • Node.js HTTP Bridge: Efficiently adapts Node incoming messages into Web standard Request without external dependencies, and streams the Web Response with chunk backpressure (drain), multi-cookie preservation via response.headers.getSetCookie(), and client disconnect cancellation (reader.cancel()).
    • Callable Handler Set: The returned handler carries named HTTP method exports (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, fetch) and .listenIfStandalone(), supporting both universal default export and named destructuring.
    • Standalone Runner Support: listenIfStandalone(handler, options?), isServerlessEnvironment(), and isStandaloneEnvironment() enable running the identical handler in local dev, Docker, or standalone VMs without wrapping code in environment guards.
    • Platform Identity: Adds 'vercel' to PlatformId, declared on ctx.platform === 'vercel'.

@nextrush/validation

Minor Changes

  • #78 4bb3dbf Thanks @0xTanzim! - validate() exposes coerced query/params and accepts a failure status.

    const Query = z.object({ limit: z.coerce.number().int().min(1).default(50) });
    
    app.get('/items', validate({ query: Query }, { errorStatus: 422 }), (ctx) => {
      const { query } = validated(ctx); // { limit: number } — coerced
      ctx.json({ limit: query.limit });
    });
    • Coerced query/params are no longer discarded. They are written to ctx.state.validated and
      read back with the new validated(ctx) accessor, which returns {} when no validate() ran so a
      destructure never throws. Only targets that were configured and passed appear. Nothing is written
      on failure, so the existing atomicity guarantee holds.

    • Strict type safety and helpers. validated is fully generic (validated<{ query: MyQuery }>(ctx))
      and provides target-specific helpers (validated.query<T>(ctx), validated.params<T>(ctx), validated.body<T>(ctx))
      for cast-free typing under TypeScript strict mode.

    • ctx.query and ctx.params are still left unmodified. They are declared as string maps, so writing
      a coerced number back would make the type disagree with the runtime. The coerced values live on
      ctx.state (which is unknown-valued) instead.

    • createValidate() factory. For projects where an API specification mandates 422 (or any custom status)
      across dozens of routers, createValidate({ errorStatus: 422 }) creates a preconfigured validate function
      so the status option does not need to be repeated on every route.

    • ValidationError accepts an optional status, defaulting to 400, so new ValidationError(issues)
      is unchanged for every existing caller. validate(arg, { errorStatus }) threads it through.
      ValidationError.fromField and fromFields also accept optional status.

    • errorHandler({ validationErrorStatus: 422 }) provides a global fallback in @nextrush/errors
      mapping default 400 validation errors to 422.

    • The error code stays VALIDATION_ERROR at any status: the code names the kind of failure, the
      status names its class. A 422 validation failure still aggregates every issue across every target.

    • errorStatus is validated at construction and must be an integer 400-499, so a typo throws a
      RangeError at startup instead of producing an invalid status at request time. Without this guard an
      out-of-range value reached res.writeHead(), whose asynchronous ERR_HTTP_INVALID_STATUS_CODE is an
      uncaught exception that takes the whole process down — a config typo became a remote DoS.

    • Stacking validate() on one route merges the coerced targets instead of the second call
      clobbering the first, so validate({ params }) then validate({ query }) keeps both.

    • A body schema without a body parser now names the real cause. Previously a request that carried
      a body but had no parser installed failed with "expected object, received undefined", which blames the
      schema. It now throws an error naming the missing bodyParser(); the client still receives an opaque
      5xx and the developer gets the cause in the log.

    • A misspelled or unknown schema target is rejected at construction. validate({ querys: Schema })
      used to validate nothing and silently pass every request through — the worst failure mode for a
      validation middleware, because it looks like it works. Unknown keys, and targets whose value is not a
      Standard Schema, now throw a TypeError naming the offending key. An empty map stays a documented
      pass-through.

Patch Changes

Installation

pnpm add nextrush@4.2.0