var express = require('express');
var app = express();
var middleware = {
requireAuthentication: function(req, res, next){
console.log("private route hit");
next();
}
};
app.use(middleware.requireAuthentication());
app.get('/about',
function(req, res){
res.send('You clicked on about!');
}
);
var projectDir = __dirname + '/public';
app.use(express.static(projectDir));
app.listen(3000), function(){
console.log('Static service started');
};
I get the error (when trying to run the server) that next() is not a function. I've been following a tutorial on Nodejs and it works just fine for them. What is the issue I am having here?
foo(bar())always callsbarfirst and passes the return value tofoo.requireAuthenticationis not supposed to be called by you.