Clean up how route handlers are called
This commit is contained in:
@@ -18,13 +18,13 @@ const methodParser = z.union([
|
||||
export type Method = z.infer<typeof methodParser>;
|
||||
|
||||
const massageMethod = (input: string): Method => {
|
||||
const r = methodParser.parse(input.toUpperCase())
|
||||
const r = methodParser.parse(input.toUpperCase());
|
||||
|
||||
return r;
|
||||
};
|
||||
|
||||
export type DenoRequest = globalThis.Request;
|
||||
export type DenoResponse=globalThis.Response;
|
||||
export type DenoResponse = globalThis.Response;
|
||||
export type UserRequest = {};
|
||||
export type Request = {
|
||||
pattern: string;
|
||||
@@ -33,10 +33,14 @@ export type Request = {
|
||||
parameters: object;
|
||||
denoRequest: globalThis.Request;
|
||||
};
|
||||
|
||||
export type InternalHandler = (req: DenoRequest) => Promise<Response>;
|
||||
|
||||
export type Handler = (req: Request) => Promise<Response> | Response;
|
||||
export type ProcessedRoute = {
|
||||
pattern: URLPattern;
|
||||
method: Method;
|
||||
handler: Handler;
|
||||
handler: InternalHandler;
|
||||
};
|
||||
|
||||
export type Response = {
|
||||
@@ -45,8 +49,6 @@ export type Response = {
|
||||
result: string;
|
||||
};
|
||||
|
||||
export type Handler = (req: Request) => Promise<Response>;
|
||||
|
||||
export type Route = {
|
||||
path: string;
|
||||
methods: Method[];
|
||||
|
||||
Reference in New Issue
Block a user