The simplest flash implementation for Express.
npm i flash
app.use(session()); // session middleware
app.use(require('flash')());
app.use(function (req, res) {
// flash a message
req.flash('info', 'hello!');
next();
})
for message in flash
a.alert(class='alert-' + message.type)
p= message.message
while message = flash.shift() // consume messages as jade reads them
a.alert(class='alert-' + message.type)
p= message.message
Flash a message defaulting the type
to info
.
An array of flash messages of the form:
{
"type": "info",
"message": "message"
}