import { Middleware } from "./middleware.mjs"; import { Endpoint } from "./endpoint.mjs"; //#region src/router.d.ts interface RouterConfig { throwError?: boolean; basePath?: string; routerMiddleware?: Array<{ path: string; middleware: Middleware; }>; /** * additional Context that needs to passed to endpoints * * this will be available on `ctx.context` on endpoints */ routerContext?: Record; /** * A callback to run before any response */ onResponse?: (response: Response, request: Request) => any | Promise; /** * A callback to run before any request */ onRequest?: (request: Request) => any | Promise; /** * A callback to run when an error is thrown in the router or middleware. * * @param error - the error that was thrown in the router or middleware. * @returns a Response object that will be returned to the client. */ onError?: (error: unknown, request: Request) => void | Promise | Response | Promise; /** * List of allowed media types (MIME types) for the router * * if provided, only the media types in the list will be allowed to be passed in the body. * * If an endpoint has allowed media types, it will override the router's allowed media types. * * @example * ```ts * const router = createRouter({ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"], * }) */ allowedMediaTypes?: string[]; /** * Skip trailing slashes * * @default false */ skipTrailingSlashes?: boolean; /** * Open API route configuration */ openapi?: { /** * Disable openapi route * * @default false */ disabled?: boolean; /** * A path to display open api using scalar * * @default "/api/reference" */ path?: string; /** * Scalar Configuration */ scalar?: { /** * Title * @default "Open API Reference" */ title?: string; /** * Description * * @default "Better Call Open API Reference" */ description?: string; /** * Logo URL */ logo?: string; /** * Scalar theme * @default "saturn" */ theme?: string; }; }; } declare const createRouter: , Config extends RouterConfig>(endpoints: E, config?: Config) => { handler: (request: Request) => Promise; endpoints: E; }; type Router = ReturnType; //#endregion export { Router, RouterConfig, createRouter }; //# sourceMappingURL=router.d.mts.map