;
declare global {
function addEventListener(type: 'fetch', handler: FetchHandler): void;
}
/**
* Return the `handler` with an `event.respondWith` wrapper.
* @param {ResponseHandler} handler
*/
export function reply(handler: ResponseHandler): FetchHandler;
/**
* Assign the `handler` to the "fetch" event.
* @note Your `handler` will be wrapped by `reply` automatically.
* @param {ResponseHandler} handler
*/
export function listen(handler: ResponseHandler): void;
export type Route = { params: Params; handler: Handler };
export type Handler = (req: ServerRequest
, res: ServerResponse) => Promisable;
export type RouteParams =
T extends `${infer Prev}/*/${infer Rest}`
? RouteParams & { wild: string } & RouteParams
: T extends `${string}:${infer P}?/${infer Rest}`
? { [K in P]?: string } & RouteParams
: T extends `${string}:${infer P}/${infer Rest}`
? { [K in P]: string } & RouteParams
: T extends `${string}:${infer P}?`
? { [K in P]?: string }
: T extends `${string}:${infer P}`
? { [K in P]: string }
: T extends `${string}*`
? { wild: string }
: {};
export declare class Router {
add(method: string, route: T, handler: Handler): void;
add(method: string, route: T, handler: Handler>): void;
find(method: string, pathname: string): Route|void;
run(event: FetchEvent): Promise;
onerror(req: ServerRequest, res: ServerResponse, status?: number, error?: Error): Promisable;
prepare?(req: Omit, res: ServerResponse): Promisable;
}
// TODO?: worktop/status | worktop/errors
export declare var STATUS_CODES: Record;
/**
* Compose multiple `Handler` functions together, creating a final handler.
*/
export function compose(...handlers: Handler
[]): Handler
;