Askr documentation
Generated API snapshot

@askrjs/server/router

Exports from the declarations published in @askrjs/server. Signatures reflect the published artifact.

Exports

This entrypoint publishes 3 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

ApiRouteOptionstype

ApiRouteOptions: any

Per-route configuration shared by {@link ApiRoute}.

auth
auth?: AuthRequirement;
middleware
middleware?: readonly Middleware<RouteParams>[];
maxRequestBytes
maxRequestBytes?: number;

createRoutertype

createRouter: () => Router

Creates an empty, mutable {@link Router} with chainable HTTP-method route builders (get, post, put, patch, delete, options, head, trace, connect, ws) and a use method for registering middleware.

Routertype

Router: any

A mutable collection of routes and middleware, built with chainable per-method registration methods (each returning the router itself for chaining) and a use method for middleware.

routes
readonly routes: readonly ApiRoute[];
middleware
readonly middleware: readonly Middleware[];
use
use(...middleware: Middleware[]): Router;
route
route<const Path extends string>(method: string | readonly string[], path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
get
get<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
post
post<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
put
put<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
patch
patch<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
delete
delete<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
options
options<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
head
head<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
trace
trace<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
connect
connect<const Path extends string>(path: Path, handler: Handler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;
ws
ws<const Path extends string>(path: Path, handler: WebSocketHandler<PathParams<Path>>, options?: ApiRouteOptions<PathParams<Path>>): Router;