app.js
This file
Path
examples/app.js
65 lines · 1.3 KiB · JavaScript
Last changed by
Long-polling chat example appvisionmediabefore adoptionb75e1ee
History of this fileTake it
The walk stopped after 200 commits: lines older than f421443 point at it.
Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
line 1why, one step back1Cleaning up example appvisionmediabefore adoption05e9cc6
line 2why, one step back2require.paths.unshift('lib')Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
line 3why, one step back3require('express')Added plugins.js for quick plugin mixinsvisionmediabefore adoption39b0e43
line 4why, one step back4require('express/plugins')Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
line 5why, one step back5Defaulting 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
line 10why, one step back10 set('root', dirname(__filename))Added "helpful 404" support pagevisionmediabefore adoption897c590
line 11why, one step back11 enable('helpful 404')Added "show exceptions" setting and specsvisionmediabefore adoptiondad297e
line 12why, one step back12 enable('show exceptions')Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51
lines 13–15why, one step back13 enable('cache views')14})15Make route params request specificvisionmediabefore adoptiond0dae12
lines 16–18why, one step back16var messages = [],17 path = require('path'),18 posix = require('posix')Added chat example (though not practical over http)visionmediabefore adoption9c5552c
line 19why, one step back19CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
line 20why, one step back20get('/', function(){Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764
line 21why, one step back21 this.redirect('/chat')CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 22–23why, one step back22})23Started chat examplevisionmediabefore adoption654c526
line 24why, one step back24get('/chat', function(){Moved render() to Requestvisionmediabefore adoptione182388
line 25why, one step back25 this.render('chat.haml.html', {Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 26–29why, one step back26 locals: {27 messages: messages28 }29 })Cleaning up example appvisionmediabefore adoption05e9cc6
line 30why, one step back30})Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
line 31why, one step back31Added chat example (though not practical over http)visionmediabefore adoption9c5552c
line 32why, one step back32post('/chat', function(){Moved render() to Requestvisionmediabefore adoptione182388
line 33why, one step back33 messages.push(this.param('message'))Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764
line 34why, one step back34 this.halt(200)Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 35–37why, one step back35})3637get('/chat/messages', function(){Long-polling chat example appvisionmediabefore adoptionb75e1ee
lines 38–46why, one step back38 var self = this,39 previousLength = messages.length,40 timer = setInterval(function(){41 if (messages.length > previousLength)42 self.contentType('json'),43 previousLength = messages.length,44 self.halt(200, JSON.encode(messages)),45 clearInterval(timer)46 }, 100)Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
lines 47–48why, one step back47})48Make route params request specificvisionmediabefore adoptiond0dae12
line 49why, one step back49get('/public/:file', function(file){Moved render() to Requestvisionmediabefore adoptione182388
lines 50–58why, one step back50 var self = this51 file = dirname(__filename) + '/public/' + file52 path.exists(file, function(exists){53 if (!exists) self.halt()54 posix.cat(file).addCallback(function(content){55 self.contentType(file)56 self.halt(200, content)57 })58 })More example app stylingvisionmediabefore adoptionbb2e79f
lines 59–60why, one step back59})60Started show exceptions supportvisionmediabefore adoptione728d3c
lines 61–64why, one step back61get('/error', function(){62 throw new Error('oh noes!')63})64Refactored Collection#keys() with #map()visionmediabefore adoptionf421443
line 65why, one step back65run()