import { IncomingMessage, Server as HttpServer, ServerResponse } from 'http'; import { ParsedUrl } from './parseUrl'; export interface Request extends IncomingMessage { params: Record; param: Record; path: string; query: Record; search: string | null; /** @private */ _parseUrlCache?: ParsedUrl; } export type Response = ServerResponse; export type ErrorType = any; export type NextFunction = (e?: ErrorType) => void; export type RequestHandler = (req: Request, res: Response, next: NextFunction) => void; export type ErrorHandler = (e: ErrorType, req: Request, res: Response, next: NextFunction) => void; export interface HttpServerOptions { server?: HttpServer; onError?: ErrorHandler; } export type HttpMethod = 'HEAD' | 'OPTIONS' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'CONNECT' | 'TRACE'; export interface RouteLayer { regex: RegExp; method?: HttpMethod; paramNames: string[]; callbacks: RequestHandler[]; componentsToDrop: number; } export interface FoundCallback { params: Record; callback: RequestHandler; componentsToDrop: number; }