Implements basic file based router

This commit is contained in:
2025-01-02 16:06:55 -07:00
parent defd40293f
commit b73af68989
11 changed files with 464 additions and 72 deletions

12
types.ts Normal file → Executable file
View File

@@ -11,8 +11,14 @@ export interface RouterContext {
request: Request;
}
export type Handler = (req: Request, ctx: RouterContext) => Promise<Response> | Response;
export type Middleware = (ctx: RouterContext, next: () => Promise<Response>) => Promise<Response>;
export type Handler = (
req: Request,
ctx: RouterContext,
) => Promise<Response> | Response;
export type Middleware = (
ctx: RouterContext,
next: () => Promise<Response>,
) => Promise<Response>;
export interface RouteConfig {
pattern: URLPattern;
@@ -32,4 +38,4 @@ export interface RouteConfigurator {
delete(handler: Handler): RouteConfigurator;
patch(handler: Handler): RouteConfigurator;
options(handler: Handler): RouteConfigurator;
}
}