Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than e958988 point at it.

styling for stylus exampleTj Holowaychukbefore adoptione958988

lines 1–13why, one step back
1
2// 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 back
14 express.cookieParser()

styling for stylus exampleTj Holowaychukbefore adoptione958988

lines 15–23why, one step back
15 , express.session({ secret: 'keyboard cat' })
16);1718// View settings1920app.set('views', __dirname + '/views');21app.set('view engine', 'ejs');2223app.dynamicHelpers({

Fixed flash exampleTj Holowaychukbefore adoption85d2254

lines 24–27why, one step back
24 // express-messages is a dynamicHelper that
25 // renders the flash messages to HTML for you26 // $ npm install express-messages27 messages: require('express-messages')

styling for stylus exampleTj Holowaychukbefore adoptione958988

lines 28–49why, one step back
28});
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');