Skip to content
Myr

app.js

This file

Path

examples/app.js

58 lines · 1.2 KiB · JavaScript

Last changed by

Added smilie support to sample chat app :)visionmediabefore adoption223d764

History of this file

Take it

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

Fixed wiki urivisionmediabefore adoptionf09358b

lines 1–8why, one step back
1
2require.paths.unshift('lib')3require('express')4require('express/plugins')56configure(function(){7 use(MethodOverride)8 use(ContentLength)

Moving CommonLogger in sample app lower to catch Content-Lengthvisionmediabefore adoption45cd102

line 9why, one step back
9 use(CommonLogger)

Fixed wiki urivisionmediabefore adoptionf09358b

lines 10–13why, one step back
10 set('root', dirname(__filename))
11 enable('cache views')12})13

Make route params request specificvisionmediabefore adoptiond0dae12

line 14why, one step back
14var messages = [],

Added static file support [#17]visionmediabefore adoption542a90a

line 15why, one step back
15 StaticFile = require('express/static').File

Hooks are now called in context to the requestvisionmediabefore adoption202c74d

line 16why, one step back
16

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

line 17why, one step back
17get('/', function(){

Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764

line 18why, one step back
18 this.redirect('/chat')

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

lines 19–20why, one step back
19})
20

Started chat examplevisionmediabefore adoption654c526

line 21why, one step back
21get('/chat', function(){

Misc refactoringvisionmediabefore adoption79cf45a

line 22why, one step back
22 this.render('chat.haml.html', {

Added chat example (though not practical over http)visionmediabefore adoption9c5552c

lines 23–26why, one step back
23 locals: {
24 messages: messages25 }26 })

Fixed wiki urivisionmediabefore adoptionf09358b

lines 27–28why, one step back
27})
28

Added chat example (though not practical over http)visionmediabefore adoption9c5552c

line 29why, one step back
29post('/chat', function(){

Added smilie support to sample chat app :)visionmediabefore adoption223d764

line 30why, one step back
30 messages.push(escape(this.param('message')).replace(/:\)/g, '<img src="http://icons3.iconfinder.netdna-cdn.com/data/icons/ledicons/emoticon_smile.png">'))

Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764

line 31why, one step back
31 this.halt(200)

Added chat example (though not practical over http)visionmediabefore adoption9c5552c

lines 32–34why, one step back
32})
3334get('/chat/messages', function(){

Long-polling chat example appvisionmediabefore adoptionb75e1ee

lines 35–43why, one step back
35 var self = this,
36 previousLength = messages.length,37 timer = setInterval(function(){38 if (messages.length > previousLength)39 self.contentType('json'),40 previousLength = messages.length,41 self.halt(200, JSON.encode(messages)),42 clearInterval(timer)43 }, 100)

Fixed wiki urivisionmediabefore adoptionf09358b

lines 44–45why, one step back
44})
45

Splat for sendfile() in example appvisionmediabefore adoption0554cbb

line 46why, one step back
46get('/public/*', function(file){

Added Request#sendfile()visionmediabefore adoptionfc54985

line 47why, one step back
47 this.sendfile(dirname(__filename) + '/public/' + file)

More example app stylingvisionmediabefore adoptionbb2e79f

lines 48–49why, one step back
48})
49

Added /error/view to example appvisionmediabefore adoptiona974b8b

lines 50–53why, one step back
50get('/error/view', function(){
51 this.render('does.not.exist')52})53

Started show exceptions supportvisionmediabefore adoptione728d3c

lines 54–57why, one step back
54get('/error', function(){
55 throw new Error('oh noes!')56})57

Fixed wiki urivisionmediabefore adoptionf09358b

line 58why, one step back
58run()