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 fileTake it
The walk stopped after 200 commits: lines older than f09358b point at it.
Fixed wiki urivisionmediabefore adoptionf09358b
lines 1–8why, one step back12require.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 back9 use(CommonLogger)Fixed wiki urivisionmediabefore adoptionf09358b
lines 10–13why, one step back10 set('root', dirname(__filename))11 enable('cache views')12})13Make route params request specificvisionmediabefore adoptiond0dae12
line 14why, one step back14var messages = [],Added static file support [#17]visionmediabefore adoption542a90a
line 15why, one step back15 StaticFile = require('express/static').FileHooks are now called in context to the requestvisionmediabefore adoption202c74d
line 16why, one step back16 CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
line 17why, one step back17get('/', function(){Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764
line 18why, one step back18 this.redirect('/chat')CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 19–20why, one step back19})20Started chat examplevisionmediabefore adoption654c526
line 21why, one step back21get('/chat', function(){Misc refactoringvisionmediabefore adoption79cf45a
line 22why, one step back22 this.render('chat.haml.html', {Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 23–26why, one step back23 locals: {24 messages: messages25 }26 })Fixed wiki urivisionmediabefore adoptionf09358b
lines 27–28why, one step back27})28Added chat example (though not practical over http)visionmediabefore adoption9c5552c
line 29why, one step back29post('/chat', function(){Added smilie support to sample chat app :)visionmediabefore adoption223d764
line 30why, one step back30 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 back31 this.halt(200)Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 32–34why, one step back32})3334get('/chat/messages', function(){Long-polling chat example appvisionmediabefore adoptionb75e1ee
lines 35–43why, one step back35 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 back44})45Splat for sendfile() in example appvisionmediabefore adoption0554cbb
line 46why, one step back46get('/public/*', function(file){Added Request#sendfile()visionmediabefore adoptionfc54985
line 47why, one step back47 this.sendfile(dirname(__filename) + '/public/' + file)More example app stylingvisionmediabefore adoptionbb2e79f
lines 48–49why, one step back48})49Added /error/view to example appvisionmediabefore adoptiona974b8b
lines 50–53why, one step back50get('/error/view', function(){51 this.render('does.not.exist')52})53Started show exceptions supportvisionmediabefore adoptione728d3c
lines 54–57why, one step back54get('/error', function(){55 throw new Error('oh noes!')56})57Fixed wiki urivisionmediabefore adoptionf09358b
line 58why, one step back58run()