Skip to content

Instantly share code, notes, and snippets.

@dgaubert
Created September 25, 2017 17:54
Show Gist options
  • Save dgaubert/abdd49465d25094831db0d938321a375 to your computer and use it in GitHub Desktop.
Save dgaubert/abdd49465d25094831db0d938321a375 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const mw1Factory = function () {
return function mw1 (req, res, next) {
next();
}
}
const mws = [
mw1Factory(),
function mw2 (req, res, next) {
next();
}
]
app.use(mws, function mw3 (req, res, next) {
next();
});
app.use(function mw4 (req, res, next) {
next();
});
app.listen(3000);
@dgaubert
Copy link
Author

$ DEBUG=express:* node test.js
=>
express:router dispatching GET / +5s
express:router query : / +1ms
express:router expressInit : / +1ms
express:router mw1 : / +0ms
express:router mw2 : / +1ms
express:router mw3 : / +0ms
express:router mw4 : / +0ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment