app.js
This file
Path
examples/app.js
54 lines · 1.0 KiB · JavaScript
Last changed by
Added Request#sendfile()visionmediabefore adoptionfc54985
History of this fileTake it
The walk stopped after 200 commits: lines older than 0a1ef27 point at it.
Added Profiler pluginvisionmediabefore adoption0a1ef27
line 1why, one step back1Cleaning up example appvisionmediabefore adoption05e9cc6
line 2why, one step back2require.paths.unshift('lib')Added Profiler pluginvisionmediabefore adoption0a1ef27
lines 3–5why, one step back3require('express')4require('express/plugins')5Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51
line 6why, one step back6configure(function(){Cleaning up example appvisionmediabefore adoption05e9cc6
lines 7–8why, one step back7 use(MethodOverride)8 use(ContentLength)Moving CommonLogger in sample app lower to catch Content-Lengthvisionmediabefore adoption45cd102
line 9why, one step back9 use(CommonLogger)Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51
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(){Moved render() to Requestvisionmediabefore adoptione182388
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 })Cleaning up example appvisionmediabefore adoption05e9cc6
line 27why, one step back27})Added Profiler pluginvisionmediabefore adoption0a1ef27
line 28why, one step back28Added chat example (though not practical over http)visionmediabefore adoption9c5552c
line 29why, one step back29post('/chat', function(){Escaping sample chat app messagesvisionmediabefore adoptiond94ed67
line 30why, one step back30 messages.push(escape(this.param('message')))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)Added Profiler pluginvisionmediabefore adoption0a1ef27
lines 44–45why, one step back44})45Make route params request specificvisionmediabefore adoptiond0dae12
line 46why, one step back46get('/public/:file', 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})49Started show exceptions supportvisionmediabefore adoptione728d3c
lines 50–53why, one step back50get('/error', function(){51 throw new Error('oh noes!')52})53Added Profiler pluginvisionmediabefore adoption0a1ef27
line 54why, one step back54run()