This question has been asked a million times already, but I never really understood the answers and when I did, they did not suit my specific needs.
I currently have flash messages implemented using this:
app.use(function(req, res, next){
res.locals.sessionFlash = req.session.sessionFlash;
delete req.session.sessionFlash;
next();
});
And when I want to use the message in a route, I have to explicitly recall it like this:
res.render('...', {
sessionFlash: res.locals.sessionFlash
});
Is there a simpler way to do this (preferably one where I would not need to pull the messages from the session manually)?