import { IncomingMessage, ServerResponse } from 'http'; import { Http2ServerRequest, Http2ServerResponse } from 'http2'; declare function Router( config?: Router.Config ): Router.Instance; declare namespace Router { enum HTTPVersion { V1 = 'http1', V2 = 'http2' } type HTTPMethod = | 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE'; type Req = V extends HTTPVersion.V1 ? IncomingMessage : Http2ServerRequest; type Res = V extends HTTPVersion.V1 ? ServerResponse : Http2ServerResponse; type Handler = ( req: Req, res: Res, params: { [k: string]: string | undefined }, store: any ) => void; interface Config { ignoreTrailingSlash?: boolean; allowUnsafeRegex?: boolean; caseSensitive?: boolean; maxParamLength?: number; defaultRoute?( req: Req, res: Res ): void; onBadUrl?( path: string, req: Req, res: Res ): void; versioning? : { storage() : { get(version: String) : Handler | null, set(version: String, store: Handler) : void, del(version: String) : void, empty() : void }, deriveVersion(req: Req, ctx?: Context) : String, } } interface RouteOptions { version: string; } interface ShortHandRoute { (path: string, handler: Handler): void; (path: string, opts: RouteOptions, handler: Handler): void; (path: string, handler: Handler, store: any): void; (path: string, opts: RouteOptions, handler: Handler, store: any): void; } interface FindResult { handler: Handler; params: { [k: string]: string | undefined }; store: any; } interface Instance { on( method: HTTPMethod | HTTPMethod[], path: string, handler: Handler ): void; on( method: HTTPMethod | HTTPMethod[], path: string, options: RouteOptions, handler: Handler ): void; on( method: HTTPMethod | HTTPMethod[], path: string, handler: Handler, store: any ): void; on( method: HTTPMethod | HTTPMethod[], path: string, options: RouteOptions, handler: Handler, store: any ): void; off(method: HTTPMethod | HTTPMethod[], path: string): void; lookup( req: Req, res: Res, ctx?: Context ): void; find( method: HTTPMethod, path: string, version?: string ): FindResult | null; reset(): void; prettyPrint(): string; all: ShortHandRoute; acl: ShortHandRoute; bind: ShortHandRoute; checkout: ShortHandRoute; connect: ShortHandRoute; copy: ShortHandRoute; delete: ShortHandRoute; get: ShortHandRoute; head: ShortHandRoute; link: ShortHandRoute; lock: ShortHandRoute; 'm-search': ShortHandRoute; merge: ShortHandRoute; mkactivity: ShortHandRoute; mkcalendar: ShortHandRoute; mkcol: ShortHandRoute; move: ShortHandRoute; notify: ShortHandRoute; options: ShortHandRoute; patch: ShortHandRoute; post: ShortHandRoute; propfind: ShortHandRoute; proppatch: ShortHandRoute; purge: ShortHandRoute; put: ShortHandRoute; rebind: ShortHandRoute; report: ShortHandRoute; search: ShortHandRoute; source: ShortHandRoute; subscribe: ShortHandRoute; trace: ShortHandRoute; unbind: ShortHandRoute; unlink: ShortHandRoute; unlock: ShortHandRoute; unsubscribe: ShortHandRoute; } } export = Router;