[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:
Andrea Gueugnaut
2018-11-18 09:40:30 -08:00
committed by Pranav Senthilnathan
parent 84b817e096
commit 2b4c81593a
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -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.
+2
View File
@@ -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