Catch-all request handler for platform adapters.
Contract configs registered through the routes option.
Build a fully assembled request context from a framework-neutral request.
Use this for adapter entry points outside the route pipeline, such as server components or upload routes.
Build a fully assembled service context for schedules, outbox drains, tasks, and background work.
Requires context.service to be declared in createServer(...).
Only call this from long-lived runtimes such as servers, workers, and
bun test. It enters the ambient correlation context with
AsyncLocalStorage.enterWith, and resuming that frame across top-level
await crashes Bun 1.3.x in plain scripts. Seeds and one-off scripts must
use runServiceContext(...) instead.
Final app ports after provider setup.
Build a handler for a route that cannot be a contract — webhooks,
third-party auth callbacks, streaming endpoints — that still runs the
whole server pipeline: correlation, onRequest, route hooks,
beforeHandle, beforeSend, afterSend, context creation,
instrumentation, and framework error mapping.
Request parsing and validation are skipped and the request body is left
unconsumed, so the handler owns body reading — for example webhook
signature verification over the exact raw bytes. Metadata-driven hooks
such as rate limiting and idempotency read init.metadata. Raw routes
are not added to the route registry; mount the returned handler at the
route's own path.
Register and build a single route handler imperatively.
Build a service context and run fn inside a scoped ambient correlation
frame, returning its result.
This is the script-safe counterpart to createServiceContext(...): the
ambient frame is entered with AsyncLocalStorage.run, so plain scripts
such as seeds and one-off maintenance work stay safe under top-level
await. Requires context.service to be declared in createServer(...).
Stop installed providers in reverse setup order.
Runtime server object returned by
createServer(...).