23 lines
730 B
TypeScript
23 lines
730 B
TypeScript
import { IncomingMessage, ServerResponse } from "node:http";
|
|
|
|
export interface Request extends Omit<IncomingMessage, 'url'> {
|
|
url: {
|
|
pathname: string;
|
|
split: string[];
|
|
searchParams: URLSearchParams;
|
|
qs: Record<string, string>;
|
|
};
|
|
cookies?: Record<string, string>;
|
|
params?: Record<string, string>;
|
|
post?: Record<string, string>;
|
|
}
|
|
|
|
export interface Response extends ServerResponse {
|
|
reply: (options: { code?: number; type?: string; body: string }) => void;
|
|
json: (body: string, code?: number) => void;
|
|
html: (body: string, code?: number) => void;
|
|
redirect: (target: string, code?: number) => void;
|
|
}
|
|
|
|
export type Handler = (req: Request, res: Response, next?: () => void) => void | Promise<void>;
|