diff --git a/express/express-tests.ts b/express/express-tests.ts index 27ba253c1..a0f10f6e9 100644 --- a/express/express-tests.ts +++ b/express/express-tests.ts @@ -1246,6 +1246,16 @@ if (!module.parent) { ////// +var router = new express.Router(); + +router.get('/', function (req, resp, next?) { + resp.send('response from router'); + resp.end(); + if (next) { + next(); + } +}); + function test_general() { app.use(function (err, req, res, next) { @@ -1478,4 +1488,5 @@ function test_middleware() { app.use(express.cookieSession()); app.use(express.directory('public')); app.use(express.static('public')); + app.use(router.middleware); } diff --git a/express/express.d.ts b/express/express.d.ts index 12456ac8e..268598358 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -62,6 +62,14 @@ declare module "express" { new (method: string, path: string, callbacks: Function[], options: any): Route; } + export class Router { + new (options: any): Router; + + middleware (): any; + + get(path: string, ...handlers: RequestFunction[]): Router; + } + interface Handler { (req: Request, res: Response, next?: Function): void; }