creating a middleware for express.js app
const express = require('express');
const app = express();
const sayHello = function(options = {}) {
return function (req, res, next) {
console.log('hello');
next();
}
};
const sayHolla = function(option = {}) {
return function (req, res, next) {
console.log('wolf');
next();
}
}
app.use('/', sayHello(), sayHolla(), (req, res) => {
res.end();
});
app.listen(3000);