Implements basic file based router
This commit is contained in:
12
types.ts
Normal file → Executable file
12
types.ts
Normal file → Executable 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user