cloudflare-worker-router-typescript
Version:
Cloudflare Worker Router Typescript is a lightweight Express-like router library for Cloudflare Workers including service workers, modules, and Durable Objects
21 lines (20 loc) • 619 B
TypeScript
/// <reference types="@cloudflare/workers-types" />
export declare type RouterHandler = (req: RouterRequest, res: RouterResponse, next: RouterNext) => any;
export declare type RouterRequest<E = any> = {
request: Request;
env?: E;
ctx?: ExecutionContext;
method: string;
params: Record<string, string>;
query: Record<string, string>;
headers: Headers;
body: any;
};
export declare type RouterResponse = {
headers: Record<string, string>;
status?: number;
response?: Response;
body?: any;
webSocket?: WebSocket;
};
export declare type RouterNext = () => Promise<void>;