koa-tree-router
Advanced tools
Comparing version 0.4.6 to 0.4.7
import * as Koa from "koa"; | ||
declare module "koa" { | ||
interface Context { | ||
params: any; | ||
} | ||
} | ||
declare namespace Router { | ||
export interface IMiddleware { | ||
(ctx: Router.IRouterContext, next: () => Promise<any>): any; | ||
} | ||
export interface IRouterOptions { | ||
onMethodNotAllowed?: Router.IMiddleware; | ||
export interface IRouterOptions<StateT = any, CustomT = {}> { | ||
onMethodNotAllowed?: Router.Middleware<StateT, CustomT>; | ||
prefix?: string; | ||
} | ||
export interface IRouterContext extends Koa.Context { | ||
export interface IRouterParamContext<StateT = any, CustomT = {}> { | ||
/** | ||
@@ -22,10 +13,26 @@ * url params | ||
params: { [key: string]: string }; | ||
/** | ||
* the router instance | ||
*/ | ||
router: Router<StateT, CustomT>; | ||
} | ||
export type RouterContext< | ||
StateT = any, | ||
CustomT = {} | ||
> = Koa.ParameterizedContext< | ||
StateT, | ||
CustomT & IRouterParamContext<StateT, CustomT> | ||
>; | ||
export interface IRouterContext extends RouterContext {} | ||
export type Middleware<StateT = any, CustomT = {}> = Koa.Middleware< | ||
StateT, | ||
CustomT & IRouterParamContext<StateT, CustomT> | ||
>; | ||
} | ||
declare class Router { | ||
declare class Router<StateT = any, CustomT = {}> { | ||
/** | ||
* Create a new router. | ||
*/ | ||
constructor(opts?: Router.IRouterOptions); | ||
constructor(opts?: Router.IRouterOptions<StateT, CustomT>); | ||
/** | ||
@@ -37,3 +44,3 @@ * Register a new route. | ||
path: string, | ||
...middleware: Array<Router.IMiddleware> | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
@@ -43,45 +50,75 @@ /** | ||
*/ | ||
get(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
get( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP POST method | ||
*/ | ||
post(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
post( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP PUT method | ||
*/ | ||
put(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
put( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP DELETE method | ||
*/ | ||
delete(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
delete( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP HEAD method | ||
*/ | ||
head(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
head( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP OPTIONS method | ||
*/ | ||
options(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
options( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP PATCH method | ||
*/ | ||
patch(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
patch( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP TRACE method | ||
*/ | ||
trace(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
trace( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* HTTP CONNECT method | ||
*/ | ||
connect(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
connect( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* Register route with all methods. | ||
*/ | ||
all(path: string, ...middleware: Array<Router.IMiddleware>): this; | ||
all( | ||
path: string, | ||
...middleware: Array<Router.Middleware<StateT, CustomT>> | ||
): this; | ||
/** | ||
* Returns router middleware. | ||
*/ | ||
routes(): Router.IMiddleware; | ||
routes(): Router.Middleware<StateT, CustomT>; | ||
} | ||
export = Router; |
{ | ||
"name": "koa-tree-router", | ||
"version": "0.4.6", | ||
"version": "0.4.7", | ||
"description": "A high performance koa router", | ||
@@ -42,4 +42,5 @@ "main": "router.js", | ||
"dependencies": { | ||
"@types/koa": "^2.0.48", | ||
"koa-compose": "^4.1.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21580
597
2
+ Added@types/koa@^2.0.48
+ Added@types/accepts@1.3.7(transitive)
+ Added@types/body-parser@1.19.5(transitive)
+ Added@types/connect@3.4.38(transitive)
+ Added@types/content-disposition@0.5.8(transitive)
+ Added@types/cookies@0.9.0(transitive)
+ Added@types/express@5.0.0(transitive)
+ Added@types/express-serve-static-core@5.0.4(transitive)
+ Added@types/http-assert@1.5.6(transitive)
+ Added@types/http-errors@2.0.4(transitive)
+ Added@types/keygrip@1.0.6(transitive)
+ Added@types/koa@2.15.0(transitive)
+ Added@types/koa-compose@3.2.8(transitive)
+ Added@types/mime@1.3.5(transitive)
+ Added@types/node@22.10.5(transitive)
+ Added@types/qs@6.9.17(transitive)
+ Added@types/range-parser@1.2.7(transitive)
+ Added@types/send@0.17.4(transitive)
+ Added@types/serve-static@1.15.7(transitive)
+ Addedundici-types@6.20.0(transitive)