mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-10-24 11:50:59 +08:00
Experimenting with Router definition
This commit is contained in:
1 parent
4cc9beb405
commit
cb2beb72e4
2 files changed
+19
No files matched your search
@@ -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);
|
||||
}
|
||||
Vendored
+8
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user