Repository navigation
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()returnsNextRouteHandlerSet— a function that also carriesGET…OPTIONSas properties. All seven names are the same dispatcher reference.- Handler sets are cached per app source in a
WeakMap, matched ontimeoutvalue andonErroridentity. 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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.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
d3cfdbfThanks @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()returnsNextRouteHandlerSet— a function that also carriesGET…OPTIONSas
properties. All seven names are the same dispatcher reference.- Handler sets are cached per app source in a
WeakMap, matched ontimeoutvalue andonError
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.
NextRouteHandlerSetis also re-exported fromnextrush/nextjs. -
#80
bd568d8Thanks @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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.mount(prefixes, subRouter)accept arrays of path prefixes (e.g.['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
- Universal Fetch (
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
4e0169aThanks @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-bunor@nextrush/adapter-denooutside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without"bunVersion") throws a descriptiveServerStartErrorwith code'ERR_RUNTIME_NOT_DETECTED'and actionable migration guidance rather than crashing with an unhandledReferenceError: Bun is not definedorReferenceError: Deno is not defined. - Optional Server / Info Parameter:
createHandler(app)in@nextrush/adapter-bunand@nextrush/adapter-denonow marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct callingawait handler(request)without supplying dummy mock server or connection info objects. - Exported Runtime Detection: Both
@nextrush/adapter-bunand@nextrush/adapter-denore-exportisBun/isDeno(andisBunRuntime/isDenoRuntime) andServerStartErrorfor straightforward runtime inspection. - Runtime Error Hierarchy: Adds
'ERR_RUNTIME_NOT_DETECTED'toServerStartErrorCodein@nextrush/runtime.
- Defensive Runtime Guarding: Calling
Patch Changes
- 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-deno
Minor Changes
-
#80
4e0169aThanks @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-bunor@nextrush/adapter-denooutside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without"bunVersion") throws a descriptiveServerStartErrorwith code'ERR_RUNTIME_NOT_DETECTED'and actionable migration guidance rather than crashing with an unhandledReferenceError: Bun is not definedorReferenceError: Deno is not defined. - Optional Server / Info Parameter:
createHandler(app)in@nextrush/adapter-bunand@nextrush/adapter-denonow marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct callingawait handler(request)without supplying dummy mock server or connection info objects. - Exported Runtime Detection: Both
@nextrush/adapter-bunand@nextrush/adapter-denore-exportisBun/isDeno(andisBunRuntime/isDenoRuntime) andServerStartErrorfor straightforward runtime inspection. - Runtime Error Hierarchy: Adds
'ERR_RUNTIME_NOT_DETECTED'toServerStartErrorCodein@nextrush/runtime.
- Defensive Runtime Guarding: Calling
Patch Changes
- 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-edge
Patch Changes
-
#80
d87f80eThanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging- AWS Lambda & ALB Hardening: Injected
statusDescriptionand broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer inPromise.race; added unhandled rejection shield on tracked tasks; setcallbackWaitsForEmptyEventLoop = 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()toStreamControllerand guardedenqueue()against client disconnects so consumer stream cancellation safely swallowsStreamAbortedErrorwithout throwing unhandledTypeErrorexceptions. - 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.
- AWS Lambda & ALB Hardening: Injected
-
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
d3cfdbfThanks @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()returnsNextRouteHandlerSet— a function that also carriesGET…OPTIONSas
properties. All seven names are the same dispatcher reference.- Handler sets are cached per app source in a
WeakMap, matched ontimeoutvalue andonError
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.
NextRouteHandlerSetis also re-exported fromnextrush/nextjs.
Patch Changes
- Updated dependencies [
914f2de,d87f80e,bd568d8,73fd473]:- @nextrush/types@4.2.0
- @nextrush/adapter-edge@1.1.1
- @nextrush/core@4.2.0
@nextrush/adapter-node
Minor Changes
-
#78
914f2deThanks @0xTanzim! -ctx.json(),ctx.html()andctx.send()accept a second argument: a numeric status or a
ResponseOptionsobject.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.statusfor 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
RangeErrorbefore the response is
committed. - Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
Set-Cookieaccumulates, an array replaces then appends, and a suppliedContent-Typewins over
the helper's automatic media type.Content-Lengthis derived from the body and is rejected. ctx.status = codeis unchanged and remains supported.
Behavior fix included: an explicitly recorded
Content-Typenow wins over a body method's default
media type in both orders, which is the behavior the adapter contract already documented. - An explicit status overrides the carried
Patch Changes
- 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-serverless
Minor Changes
-
#80
73fd473Thanks @0xTanzim! - Adds first-classcreateVercelHandlerfor 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 standardRequest(Route Handlers) and Node.js(IncomingMessage, ServerResponse)invocations. - Node.js HTTP Bridge: Efficiently adapts Node incoming messages into Web standard
Requestwithout external dependencies, and streams the WebResponsewith chunk backpressure (drain), multi-cookie preservation viaresponse.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(), andisStandaloneEnvironment()enable running the identical handler in local dev, Docker, or standalone VMs without wrapping code in environment guards. - Platform Identity: Adds
'vercel'toPlatformId, declared onctx.platform === 'vercel'.
- Universal Dual-Protocol Dispatch:
Patch Changes
-
#80
d87f80eThanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging- AWS Lambda & ALB Hardening: Injected
statusDescriptionand broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer inPromise.race; added unhandled rejection shield on tracked tasks; setcallbackWaitsForEmptyEventLoop = 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()toStreamControllerand guardedenqueue()against client disconnects so consumer stream cancellation safely swallowsStreamAbortedErrorwithout throwing unhandledTypeErrorexceptions. - 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.
- AWS Lambda & ALB Hardening: Injected
-
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
bd568d8Thanks @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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.mount(prefixes, subRouter)accept arrays of path prefixes (e.g.['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
- Universal Fetch (
Patch Changes
- Updated dependencies [
4e0169a,914f2de,bd568d8,4bb3dbf,73fd473]:- @nextrush/runtime@4.2.0
- @nextrush/types@4.2.0
- @nextrush/errors@4.2.0
@nextrush/dev
Patch Changes
-
#80
d87f80eThanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging- AWS Lambda & ALB Hardening: Injected
statusDescriptionand broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer inPromise.race; added unhandled rejection shield on tracked tasks; setcallbackWaitsForEmptyEventLoop = 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()toStreamControllerand guardedenqueue()against client disconnects so consumer stream cancellation safely swallowsStreamAbortedErrorwithout throwing unhandledTypeErrorexceptions. - 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.
- AWS Lambda & ALB Hardening: Injected
@nextrush/di
Patch Changes
@nextrush/errors
Minor Changes
-
#78
4bb3dbfThanks @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.validatedand
read back with the newvalidated(ctx)accessor, which returns{}when novalidate()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.
validatedis 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.queryandctx.paramsare 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 isunknown-valued) instead. -
createValidate()factory. For projects where an API specification mandates422(or any custom status)
across dozens of routers,createValidate({ errorStatus: 422 })creates a preconfiguredvalidatefunction
so the status option does not need to be repeated on every route. -
ValidationErroraccepts an optional status, defaulting to400, sonew ValidationError(issues)
is unchanged for every existing caller.validate(arg, { errorStatus })threads it through.
ValidationError.fromFieldandfromFieldsalso accept optionalstatus. -
errorHandler({ validationErrorStatus: 422 })provides a global fallback in@nextrush/errors
mapping default 400 validation errors to 422. -
The error
codestaysVALIDATION_ERRORat any status: the code names the kind of failure, the
status names its class. A422validation failure still aggregates every issue across every target. -
errorStatusis validated at construction and must be an integer 400-499, so a typo throws a
RangeErrorat startup instead of producing an invalid status at request time. Without this guard an
out-of-range value reachedres.writeHead(), whose asynchronousERR_HTTP_INVALID_STATUS_CODEis 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, sovalidate({ params })thenvalidate({ query })keeps both. -
A
bodyschema 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 missingbodyParser(); 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 aTypeErrornaming the offending key. An empty map stays a documented
pass-through.
-
Patch Changes
@nextrush/openapi
Patch Changes
@nextrush/router
Minor Changes
-
#80
bd568d8Thanks @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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.mount(prefixes, subRouter)accept arrays of path prefixes (e.g.['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
- Universal Fetch (
Patch Changes
@nextrush/runtime
Minor Changes
-
#80
4e0169aThanks @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-bunor@nextrush/adapter-denooutside their target runtimes (e.g., executing Bun adapter on Node.js or in a Vercel Serverless Function without"bunVersion") throws a descriptiveServerStartErrorwith code'ERR_RUNTIME_NOT_DETECTED'and actionable migration guidance rather than crashing with an unhandledReferenceError: Bun is not definedorReferenceError: Deno is not defined. - Optional Server / Info Parameter:
createHandler(app)in@nextrush/adapter-bunand@nextrush/adapter-denonow marks the secondary server/connection info parameter as optional ((request: Request, server?: ...) => Response | Promise<Response>), enabling clean direct callingawait handler(request)without supplying dummy mock server or connection info objects. - Exported Runtime Detection: Both
@nextrush/adapter-bunand@nextrush/adapter-denore-exportisBun/isDeno(andisBunRuntime/isDenoRuntime) andServerStartErrorfor straightforward runtime inspection. - Runtime Error Hierarchy: Adds
'ERR_RUNTIME_NOT_DETECTED'toServerStartErrorCodein@nextrush/runtime.
- Defensive Runtime Guarding: Calling
-
#78
914f2deThanks @0xTanzim! -ctx.json(),ctx.html()andctx.send()accept a second argument: a numeric status or a
ResponseOptionsobject.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.statusfor 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
RangeErrorbefore the response is
committed. - Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
Set-Cookieaccumulates, an array replaces then appends, and a suppliedContent-Typewins over
the helper's automatic media type.Content-Lengthis derived from the body and is rejected. ctx.status = codeis unchanged and remains supported.
Behavior fix included: an explicitly recorded
Content-Typenow wins over a body method's default
media type in both orders, which is the behavior the adapter contract already documented. - An explicit status overrides the carried
-
#80
bd568d8Thanks @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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.mount(prefixes, subRouter)accept arrays of path prefixes (e.g.['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
- Universal Fetch (
Patch Changes
- Updated dependencies [
914f2de,bd568d8,4bb3dbf,73fd473]:- @nextrush/types@4.2.0
- @nextrush/errors@4.2.0
@nextrush/stream
Patch Changes
-
#80
d87f80eThanks @0xTanzim! - fix(serverless,edge,stream,dev): harden multi-runtime handlers, streaming cancellation, and packaging- AWS Lambda & ALB Hardening: Injected
statusDescriptionand broadened detection for AWS Application Load Balancer (ALB) single-value and multi-value headers; fixed negative timeout inversion in task drainage; unref'd timer inPromise.race; added unhandled rejection shield on tracked tasks; setcallbackWaitsForEmptyEventLoop = 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()toStreamControllerand guardedenqueue()against client disconnects so consumer stream cancellation safely swallowsStreamAbortedErrorwithout throwing unhandledTypeErrorexceptions. - 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.
- AWS Lambda & ALB Hardening: Injected
-
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
914f2deThanks @0xTanzim! -ctx.json(),ctx.html()andctx.send()accept a second argument: a numeric status or a
ResponseOptionsobject.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.statusfor 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
RangeErrorbefore the response is
committed. - Supplied headers merge with recorded headers: an ordinary field overrides its earlier value,
Set-Cookieaccumulates, an array replaces then appends, and a suppliedContent-Typewins over
the helper's automatic media type.Content-Lengthis derived from the body and is rejected. ctx.status = codeis unchanged and remains supported.
Behavior fix included: an explicitly recorded
Content-Typenow wins over a body method's default
media type in both orders, which is the behavior the adapter contract already documented. - An explicit status overrides the carried
-
#80
bd568d8Thanks @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 onApplicationenabling 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:
UniversalWebContexttransparently normalizes 5 runtime signatures (1-argfetch(req), Cloudflare Workers(req, env, ctx)withctx.envandctx.waitUntil, Vercel Edge(req, ctx)withctx.waitUntil, Bun(req, server)withserver.requestIP, and Deno(req, info)withinfo.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)androuter.mount(prefixes, subRouter)accept arrays of path prefixes (e.g.['/api', '/v1']), normalizing slashes and deduplicating prefixes automatically.
- Universal Fetch (
-
#80
73fd473Thanks @0xTanzim! - Adds first-classcreateVercelHandlerfor 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 standardRequest(Route Handlers) and Node.js(IncomingMessage, ServerResponse)invocations. - Node.js HTTP Bridge: Efficiently adapts Node incoming messages into Web standard
Requestwithout external dependencies, and streams the WebResponsewith chunk backpressure (drain), multi-cookie preservation viaresponse.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(), andisStandaloneEnvironment()enable running the identical handler in local dev, Docker, or standalone VMs without wrapping code in environment guards. - Platform Identity: Adds
'vercel'toPlatformId, declared onctx.platform === 'vercel'.
- Universal Dual-Protocol Dispatch:
@nextrush/validation
Minor Changes
-
#78
4bb3dbfThanks @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.validatedand
read back with the newvalidated(ctx)accessor, which returns{}when novalidate()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.
validatedis 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.queryandctx.paramsare 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 isunknown-valued) instead. -
createValidate()factory. For projects where an API specification mandates422(or any custom status)
across dozens of routers,createValidate({ errorStatus: 422 })creates a preconfiguredvalidatefunction
so the status option does not need to be repeated on every route. -
ValidationErroraccepts an optional status, defaulting to400, sonew ValidationError(issues)
is unchanged for every existing caller.validate(arg, { errorStatus })threads it through.
ValidationError.fromFieldandfromFieldsalso accept optionalstatus. -
errorHandler({ validationErrorStatus: 422 })provides a global fallback in@nextrush/errors
mapping default 400 validation errors to 422. -
The error
codestaysVALIDATION_ERRORat any status: the code names the kind of failure, the
status names its class. A422validation failure still aggregates every issue across every target. -
errorStatusis validated at construction and must be an integer 400-499, so a typo throws a
RangeErrorat startup instead of producing an invalid status at request time. Without this guard an
out-of-range value reachedres.writeHead(), whose asynchronousERR_HTTP_INVALID_STATUS_CODEis 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, sovalidate({ params })thenvalidate({ query })keeps both. -
A
bodyschema 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 missingbodyParser(); 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 aTypeErrornaming the offending key. An empty map stays a documented
pass-through.
-
Patch Changes
- Updated dependencies [
914f2de,bd568d8,4bb3dbf,73fd473]:- @nextrush/types@4.2.0
- @nextrush/errors@4.2.0
Installation
pnpm add nextrush@4.2.0