Skip to content

@xtandard/kit/server/router

@xtandard/kit/server/router — the optional declarative router: one route table drives dispatch, auth, authorization, readonly, 405 + Allow, body validation and the generated OpenAPI 3.1 document.

import { … } from "@xtandard/kit/server/router";
Name Summary
buildOpenApiDocument Build the OpenAPI 3.1 document for a route table.
createRouter Build a router from a route table.
errorResponse A JSON error response object with description.
openApiOperation The OpenAPI operation object for one route.
ref { $ref: "#/components/schemas/<name>" }.
toOpenApiPath /a/:id/b → /a/{id}/b.
Name Summary
Call Per-request state handed to route handlers.
OpenApiOptions Options for buildOpenApiDocument.
Route A route: its spec plus the resource it targets and its handler.
RouteQueryParam A query parameter a route documents.
Router What createRouter returns.
RouterOptions Options for createRouter.
RouteSpec The documented shape of one route (consumed by the OpenAPI builder).
Name Summary
RouteMethod HTTP methods the router serves (HEAD is answered by GET routes).
Schema
Name Summary
ERROR_SCHEMA The { error, code? } body every error response uses.