req-flash
Unopinionated middleware for creating flash messages of all types for Express apps.
Usage
1. Install req-flash:
npm install req-flash
2. Register the req-flash middleware after your session middleware:
var express = ;var cookieParser = ;var session = ;var flash = ;var app = ;app;app;app;
Tipp: Use flash({ locals: 'flash' })
to magically make all flash messages available to your views by attaching them to res.locals['flash']
(or whatever you specifiy instead of 'flash').
3. Flash any amount of messages:
app;app;
"/test" redirects to "/" and outputs:
{
"successMessage": "You are successfully using req-flash",
"errorMessage": "No errors, you're doing fine"
}