app.js
This file
Path
examples/flash/app.js
49 lines · 1.2 KiB · JavaScript
Last changed by
Fixed flash exampleTj Holowaychukbefore adoption85d2254
History of this fileTake it
The walk stopped after 200 commits: lines older than a9db47f point at it.
Updated connect submoduleTj Holowaychukbefore adoptiona9db47f
lines 1–13why, one step back12// Expose modules in ./support for demo purposes3require.paths.unshift(__dirname + '/../../support');45/**6 * Module dependencies.7 */89var express = require('../../lib/express');1011// App with session support1213var app = express.createServer(typo in flash exampleTj Holowaychukbefore adoption90ec103
line 14why, one step back14 express.cookieParser()Added secret to session middleware used in examples and generated appTj Holowaychukbefore adoption7687299
line 15why, one step back15 , express.session({ secret: 'keyboard cat' })Updated connect submoduleTj Holowaychukbefore adoptiona9db47f
lines 16–23why, one step back16);1718// View settings1920app.set('views', __dirname + '/views');21app.set('view engine', 'ejs');2223app.dynamicHelpers({Fixed flash exampleTj Holowaychukbefore adoption85d2254
lines 24–27why, one step back24 // express-messages is a dynamicHelper that25 // renders the flash messages to HTML for you26 // $ npm install express-messages27 messages: require('express-messages')Updated connect submoduleTj Holowaychukbefore adoptiona9db47f
lines 28–49why, one step back28});2930app.dynamicHelpers({31 // Another dynamic helper example. Since dynamic32 // helpers resolve at view rendering time, we can33 // "inject" the "page" local variable per request34 // providing us with the request url.35 page: function(req, res){36 return req.url;37 } 38});3940app.get('/', function(req, res){41 // Not very realistic notifications but illustrates usage42 req.flash('info', 'email queued');43 req.flash('info', 'email sent');44 req.flash('error', 'delivery failed');45 res.render('index');46});4748app.listen(3000);49console.log('Express app started on port 3000');