I am newbie in node so please forgive me if i am not getting obvious.
In node.js express application for app.get function we typically pass route and view as parameters
e.g.
app.get('/users', user.list);
but in passport-google example I found that they are calling it as
app.get('/users', ensureAuthenticated, user.list);
where ensureAuthenticated is a function
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login')
}
In short this means there are multiple callbacks which while running are called in series. i tried adding couple of more functions to make it look like
app.get('/users', ensureAuthenticated, dummy1, dummy2, user.list);
and i found ensureAuthenticated, dummy1, dummy2, user.list is getting called in series.
for my specific requirement i find calling functions sequentially in above form is quite elegant solution rather that using async series. can somebody explain me how it really works and how i can implement similar functionality in general.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…