export type NextFunction = (err?: any) => void; export type SyncHandler = (req: Request, res: Response, next?: NextFunction) => void; export type AsyncHandler = (req: Request, res: Response, next?: NextFunction) => Promise; export type Handler = AsyncHandler | SyncHandler; declare const METHODS: readonly ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PRI", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"]; export type Method = (typeof METHODS)[number]; export type MiddlewareType = 'mw' | 'route'; type RegexParams = { keys: string[] | false; pattern: RegExp; }; type RIM = (...args: RouterMethodParams) => App; export interface Middleware { method?: Method; handler: Handler; path?: string; type: MiddlewareType; regex?: RegexParams; fullPath?: string; } export type MethodHandler = { path?: string | string[] | Handler; handler?: Handler; type: MiddlewareType; regex?: RegexParams; fullPath?: string; }; export type RouterHandler = Handler | Handler[] | string[]; export type RouterPathOrHandler = string | RouterHandler; export type RouterMethod = (path: string | string[] | Handler, handler?: RouterHandler, ...handlers: RouterHandler[]) => any; type RouterMethodParams = Parameters>; export type UseMethod = (path: RouterPathOrHandler | App, handler?: RouterHandler | App, ...handlers: (RouterHandler | App)[]) => any; export type UseMethodParams = Parameters>; /** * Push wares to a middleware array * @param mw Middleware arrays */ export declare const pushMiddleware: (mw: Middleware[]) => ({ path, handler, method, handlers, type, fullPaths }: MethodHandler & { method?: Method; handlers?: RouterHandler[]; fullPaths?: string[]; }) => void; /** * tinyhttp Router. Manages middleware and has HTTP methods aliases, e.g. `app.get`, `app.put` */ export declare class Router { middleware: Middleware[]; mountpath: string; parent: App; apps: Record; acl: RIM; bind: RIM; checkout: RIM; connect: RIM; copy: RIM; delete: RIM; get: RIM; head: RIM; link: RIM; lock: RIM; merge: RIM; mkactivity: RIM; mkcalendar: RIM; mkcol: RIM; move: RIM; notify: RIM; options: RIM; patch: RIM; post: RIM; pri: RIM; propfind: RIM; proppatch: RIM; purge: RIM; put: RIM; rebind: RIM; report: RIM; search: RIM; source: RIM; subscribe: RIM; trace: RIM; unbind: RIM; unlink: RIM; unlock: RIM; unsubscribe: RIM; constructor(); add(method: Method): (path: string | string[] | Handler, handler?: RouterHandler | undefined, ...handlers: RouterHandler[]) => this; msearch(...args: RouterMethodParams): this; all(...args: RouterMethodParams): this; /** * Push middleware to the stack */ use(...args: UseMethodParams): this; } export {}; //# sourceMappingURL=index.d.ts.map