default
default(
options?):object
Defined in: router.js:62
Create a new Ergo router instance.
Parameters
Section titled “Parameters”options?
Section titled “options?”catchHandler?
Section titled “catchHandler?”Function
Default catch handler for all route pipelines
debug?
Section titled “debug?”boolean
Enable pipeline debug tracing. When true,
responseAcc._trace is initialized per request with {steps, breakAt}.
defaults?
Section titled “defaults?”object
Default middleware config for declarative routes. Each key
corresponds to a pipeline stage (e.g. accepts, cookie, timeout). Route-level config
overrides these. Set a key to false to disable by default.
object
Default send() options applied to all routes
strict?
Section titled “strict?”boolean
If true, throw on unknown config keys; if false, warn
strictBody?
Section titled “strictBody?”boolean
Enforce Content-Type on POST/PUT requests
strictPatch?
Section titled “strictPatch?”boolean
Enforce Content-Type on PATCH requests
timing?
Section titled “timing?”boolean | object
Inject an X-Response-Time header measuring
pipeline execution time. Pass true for defaults (x-response-time, 3 decimal places), or
{header?: string, precision?: number} for custom configuration. Zero overhead when disabled.
transport?
Section titled “transport?”object
Transport-layer config (requestId, security, rateLimit, cors)
Returns
Section titled “Returns”_dispatcher
Section titled “_dispatcher”_dispatcher:
Instance<V1> =dispatcher
_middleware
Section titled “_middleware”_middleware:
any[] =appMiddleware
_options
Section titled “_options”_options:
object=options
_options.catchHandler?
Section titled “_options.catchHandler?”
optionalcatchHandler?:Function
_options.debug?
Section titled “_options.debug?”
optionaldebug?:boolean
_options.defaults?
Section titled “_options.defaults?”
optionaldefaults?:object
_options.send?
Section titled “_options.send?”
optionalsend?:object
_options.strict?
Section titled “_options.strict?”
optionalstrict?:boolean
_options.strictBody?
Section titled “_options.strictBody?”
optionalstrictBody?:boolean
_options.strictPatch?
Section titled “_options.strictPatch?”
optionalstrictPatch?:boolean
_options.timing?
Section titled “_options.timing?”
optionaltiming?:boolean|object
_options.transport?
Section titled “_options.transport?”
optionaltransport?:object
_pathIndex
Section titled “_pathIndex”_pathIndex:
Instance<V1> =pathIndex
_registry
Section titled “_registry”_registry:
MethodRegistry=registry
_routes
Section titled “_routes”_routes:
object[] =routes
_subRouters
Section titled “_subRouters”_subRouters:
any[] =subRouters
_transport
Section titled “_transport”_transport: {
run: {requestId:string|undefined;stop:boolean; }; } |undefined=transport
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ run: { requestId: string | undefined; stop: boolean; }; }
run(
req,res,allowedMethods?):object
Run the transport layer on a request.
Parameters
Section titled “Parameters”object
HTTP request
object
HTTP response
allowedMethods?
Section titled “allowedMethods?”Set<string>
Registered methods for this path
Returns
Section titled “Returns”object
stop=true means the response has been sent (preflight, rate limited)
requestId
Section titled “requestId”requestId:
string|undefined
stop:
boolean
undefined
_wrap: (
pipeline,routeOpts?) =>Function=wrapPipeline
Parameters
Section titled “Parameters”pipeline
Section titled “pipeline”Function | Function[]
routeOpts?
Section titled “routeOpts?”catchHandler?
Section titled “catchHandler?”Function
noSend?
Section titled “noSend?”boolean
object
Returns
Section titled “Returns”Function
delete()
Section titled “delete()”delete(
path,pipeline,routeOpts?): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Register a DELETE route.
Parameters
Section titled “Parameters”string
URL pattern (e.g. ‘/users/:id‘)
pipeline
Section titled “pipeline”Function | Function[] | RouteConfig
Handler function, pipeline array, or declarative config object
routeOpts?
Section titled “routeOpts?”object
Per-route options (only for function/array pipelines)
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
get(
path,pipeline,routeOpts?): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Register a GET route.
Parameters
Section titled “Parameters”string
URL pattern (e.g. ‘/users/:id‘)
pipeline
Section titled “pipeline”Function | Function[] | RouteConfig
Handler function, pipeline array, or declarative config object
routeOpts?
Section titled “routeOpts?”object
Per-route options (only for function/array pipelines)
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
handle()
Section titled “handle()”handle(): (
req,res) =>any
Create the Node.js HTTP request handler.
Returns
Section titled “Returns”(req, res) => any
listen()
Section titled “listen()”listen(
port, …args):Server<typeofIncomingMessage, typeofServerResponse>
Convenience: create an HTTP server and start listening.
Parameters
Section titled “Parameters”number
…any[]
Additional arguments passed to server.listen()
Returns
Section titled “Returns”Server<typeof IncomingMessage, typeof ServerResponse>
mount()
Section titled “mount()”mount(
prefix,subRouter): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Mount a sub-router at a prefix path.
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
URL prefix (e.g. ‘/api/v1’)
subRouter
Section titled “subRouter”object
Another router instance
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
patch()
Section titled “patch()”patch(
path,pipeline,routeOpts?): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Register a PATCH route.
Parameters
Section titled “Parameters”string
URL pattern (e.g. ‘/users/:id‘)
pipeline
Section titled “pipeline”Function | Function[] | RouteConfig
Handler function, pipeline array, or declarative config object
routeOpts?
Section titled “routeOpts?”object
Per-route options (only for function/array pipelines)
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
post()
Section titled “post()”post(
path,pipeline,routeOpts?): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Register a POST route.
Parameters
Section titled “Parameters”string
URL pattern (e.g. ‘/users’)
pipeline
Section titled “pipeline”Function | Function[] | RouteConfig
Handler function, pipeline array, or declarative config object
routeOpts?
Section titled “routeOpts?”object
Per-route options (only for function/array pipelines)
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
put(
path,pipeline,routeOpts?): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Register a PUT route.
Parameters
Section titled “Parameters”string
URL pattern (e.g. ‘/users/:id‘)
pipeline
Section titled “pipeline”Function | Function[] | RouteConfig
Handler function, pipeline array, or declarative config object
routeOpts?
Section titled “routeOpts?”object
Per-route options (only for function/array pipelines)
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
use(…
fns): { _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }
Add application-level middleware that runs before every route pipeline.
Parameters
Section titled “Parameters”…Function[]
Middleware functions
Returns
Section titled “Returns”{ _dispatcher: Instance<HTTPVersion.V1>; _pathIndex: Instance<HTTPVersion.V1>; _registry: MethodRegistry; _middleware: any[]; … 13 more …; delete(path: string, pipeline: Function | … 1 more … | RouteConfig, routeOpts?: object | undefined): …; }