Skip to content

Instantly share code, notes, and snippets.

@sfabijanski
Forked from raddeus/app.js
Created June 2, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfabijanski/1d630489df086d595d9044402882e91a to your computer and use it in GitHub Desktop.
Save sfabijanski/1d630489df086d595d9044402882e91a to your computer and use it in GitHub Desktop.
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
app.all('/', function(req, res){
req.flash('test', 'it worked');
res.redirect('/test')
});
app.all('/test', function(req, res){
res.send(JSON.stringify(req.flash('test')));
});
app.listen(3000);
module.exports = app;
{
"dependencies": {
"express": "^4.0.0",
"express-session": "^1.0.2",
"cookie-parser": "^1.0.1",
"connect-flash": "^0.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment