import * as Koa from "koa"; declare namespace Router { export interface IRouterOptions { onMethodNotAllowed?: Router.Middleware; } export interface IRouterParamContext { /** * url params */ params: { [key: string]: string }; /** * the router instance */ router: Router; } export type RouterContext< StateT = any, CustomT = {} > = Koa.ParameterizedContext< StateT, CustomT & IRouterParamContext >; export interface IRouterContext extends RouterContext {} export type Middleware = Koa.Middleware< StateT, CustomT & IRouterParamContext >; } declare class Router { /** * Create a new router. */ constructor(opts?: Router.IRouterOptions); /** * Register a new route. */ on( method: string, path: string, ...middleware: Array> ): this; /** * HTTP GET method */ get( path: string, ...middleware: Array> ): this; /** * HTTP POST method */ post( path: string, ...middleware: Array> ): this; /** * HTTP PUT method */ put( path: string, ...middleware: Array> ): this; /** * HTTP DELETE method */ delete( path: string, ...middleware: Array> ): this; /** * HTTP HEAD method */ head( path: string, ...middleware: Array> ): this; /** * HTTP OPTIONS method */ options( path: string, ...middleware: Array> ): this; /** * HTTP PATCH method */ patch( path: string, ...middleware: Array> ): this; /** * HTTP TRACE method */ trace( path: string, ...middleware: Array> ): this; /** * HTTP CONNECT method */ connect( path: string, ...middleware: Array> ): this; /** * Register route with all methods. */ all( path: string, ...middleware: Array> ): this; /** * Returns router middleware. */ routes(): Router.Middleware; /** * Mount the router with specific path in a koa app */ mount(path: string): Koa.Middleware; } export = Router;