also looking at this
chore: wip stx improvements
#1649
241 files
+19022
-1323
| @@ -0,0 +1,27 @@ | ||
| 1 | export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | |
| 2 | ||
| 3 | export interface HandlerContext { | |
| 4 | params: Record<string, string> | |
| 5 | request: Request | |
| 6 | headers: Headers | |
| 7 | url: URL | |
| 8 | body: unknown | |
| 9 | } | |
| 10 | ||
| 11 | export interface HandlerConfig<T = unknown> { | |
| 12 | handler: (ctx: HandlerContext) => Promise<T> | T | |
| 13 | middleware?: string[] | |
| 14 | input?: { parse: (data: unknown) => unknown } | |
| 15 | } | |
| 16 | ||
| 17 | export interface ApiRoute { | |
| 18 | path: string | |
| 19 | method: HttpMethod | |
| 20 | handler: HandlerConfig | |
| 21 | filePath: string | |
| 22 | } | |
| 23 | ||
| 24 | export interface ApiRouterConfig { | |
| 25 | apiDir: string | |
| 26 | prefix?: string | |
| 27 | } | |