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 e0ffd31 point at it.

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

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

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

lines 5–8why, one step back
5/**
6 * Module dependencies.7 */8

Fixed route-separation example requireTj Holowaychukbefore adoption487d067

line 9why, one step back
9var express = require('../../lib/express');

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

lines 10–11why, one step back
10
11var app = express.createServer(

fixed session exampleTj Holowaychukbefore adoptionbe866a7

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

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

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(),

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

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' })

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

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>');

Added development seed's cool project to applications.htmlTj Holowaychukbefore adoptione0ffd31

lines 33–35why, one step back
33});
3435app.listen(3000);

Started route separation exampleTj Holowaychukbefore adoption7ded5a2

line 36why, one step back
36console.log('Express app started on port 3000');