Separate route definitions and where they're served from
This commit is contained in:
40
deno/types.ts
Normal file
40
deno/types.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// types.ts
|
||||
|
||||
// FIXME: split this up into types used by app developers and types internal
|
||||
// to the framework.
|
||||
|
||||
|
||||
import { HttpCode, httpCodes } from "./http-codes.ts";
|
||||
import { ContentType, contentTypes } from "./content-types";
|
||||
|
||||
|
||||
export type Method = "get" | "post" | "put" | "patch" | "delete";
|
||||
|
||||
|
||||
export type DenoRequest = globalThis.Request;
|
||||
export type UserRequest = {};
|
||||
export type Request = {
|
||||
pattern: string;
|
||||
path: string;
|
||||
method: Method;
|
||||
parameters: object;
|
||||
denoRequest: globalThis.Request;
|
||||
};
|
||||
export type ProcessedRoute = { pattern: URLPattern; method: Method; handler: Handler };
|
||||
|
||||
|
||||
|
||||
export type Response = {
|
||||
code: HttpCode;
|
||||
contentType: ContentType;
|
||||
result: string;
|
||||
};
|
||||
|
||||
export type Handler = (req: Request) => Promise<Response>;
|
||||
|
||||
export type Route = {
|
||||
path: string;
|
||||
methods: Method[];
|
||||
handler: Handler;
|
||||
interruptable?: boolean
|
||||
};
|
||||
Reference in New Issue
Block a user