Skip to content
Myr

app.js

This file

Path

examples/session/app.js

36 lines · 839 bytes · JavaScript

Last changed by

Added vhost exampleTj Holowaychukbefore adoption9e9c3ee

History of this file

Take it

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

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

line 1why, one step back
1

Added vhost exampleTj Holowaychukbefore adoption9e9c3ee

lines 2–4why, one step back
2// Expose modules in ./support for demo purposes
3require.paths.unshift(__dirname + '/../../support');4

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

lines 5–11why, one step back
5/**
6 * Module dependencies.7 */89var express = require('../../lib/express');1011var app = express.createServer(

fixed session exampleTj Holowaychukbefore adoptionbe866a7

line 12why, one step back
12 express.logger(),

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

line 13why, one step back
13

fixed session exampleTj Holowaychukbefore adoptionbe866a7

lines 14–15why, one step back
14 // Required by session() middleware
15 express.cookieDecoder(),

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

line 16why, one step back
16

fixed session exampleTj Holowaychukbefore adoptionbe866a7

lines 17–19why, one step back
17 // Populates:
18 // - req.session19 // - req.sessionStore

fixed session example/tests due to connect changesTj Holowaychukbefore adoptionb1004b6

lines 20–21why, one step back
20 // - req.sessionID (or req.session.id)
21 express.session({ secret: 'keyboard cat' })

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

lines 22–24why, one step back
22);
2324app.get('/', function(req, res){

fixed session exampleTj Holowaychukbefore adoptionbe866a7

lines 25–32why, one step back
25 var body = '';
26 if (req.session.views) {27 ++req.session.views;28 } else {29 req.session.views = 1;30 body += '<p>First time visiting? view this page in several browsers :)</p>';31 }32 res.send(body + '<p>viewed <strong>' + req.session.views + '</strong> times.</p>');

master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f

lines 33–36why, one step back
33});
3435app.listen(3000);36console.log('Express app started on port 3000');