mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
[koa-router] Replace object type by an interface type for router matching (#30587)
* feat(koa-router): replace Object by IRoutesMatch; rename param * docs(koa-router): add contributor
This commit is contained in:
committed by
Pranav Senthilnathan
parent
84b817e096
commit
2b4c81593a
Vendored
+8
-1
@@ -5,6 +5,7 @@
|
||||
// JounQin <https://github.com/JounQin>
|
||||
// Romain Faust <https://github.com/romain-faust>
|
||||
// Guillaume Mayer <https://github.com/Guillaume-Mayer>
|
||||
// Andrea Gueugnaut <https://github.com/falinor>
|
||||
// Definitions: https://github.com/hellopao/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -92,6 +93,12 @@ declare namespace Router {
|
||||
query: object | string;
|
||||
}
|
||||
|
||||
export interface IRoutesMatch {
|
||||
path: Layer[];
|
||||
pathAndMethod: Layer[];
|
||||
route: boolean;
|
||||
}
|
||||
|
||||
export class ParamName {
|
||||
asterisk: boolean;
|
||||
delimiter: string;
|
||||
@@ -298,7 +305,7 @@ declare class Router {
|
||||
/**
|
||||
* Match given `path` and return corresponding routes.
|
||||
*/
|
||||
match(name: string, method: string): Object;
|
||||
match(path: string, method: string): Router.IRoutesMatch;
|
||||
|
||||
/**
|
||||
* Run middleware for named route parameters. Useful for auto-loading or validation.
|
||||
|
||||
@@ -44,6 +44,8 @@ router.get('user', '/users/:id', function (ctx) {
|
||||
ctx.body = "sdsd";
|
||||
});
|
||||
|
||||
const match = router.match('/users/:id', 'GET');
|
||||
|
||||
let layer: Router.Layer
|
||||
let layerOptions: Router.ILayerOptions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user