app.js
This file
Path
examples/app.js
55 lines · 971 bytes · JavaScript
Last changed by
CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
History of this fileTake it
The walk stopped after 200 commits: lines older than 5342d04 point at it.
Docsvisionmediabefore adoption5342d04
line 1why, one step back1Cleaning up example appvisionmediabefore adoption05e9cc6
line 2why, one step back2require.paths.unshift('lib')Docsvisionmediabefore adoption5342d04
line 3why, one step back3require('express')Added plugins.js for quick plugin mixinsvisionmediabefore adoption39b0e43
line 4why, one step back4require('express/plugins')Docsvisionmediabefore adoption5342d04
line 5why, one step back5Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51
line 6why, one step back6configure(function(){When Accept includes text/html display exceptions otherwise 500visionmediabefore adoptionbd4f150
line 7why, one step back7 use(CommonLogger)Cleaning up example appvisionmediabefore adoption05e9cc6
lines 8–9why, one step back8 use(MethodOverride)9 use(ContentLength)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})15Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 16–17why, one step back16var messages = []17CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 18–21why, one step back18get('/', function(){19 redirect('/chat')20})21Started chat examplevisionmediabefore adoption654c526
line 22why, one step back22get('/chat', function(){Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 23–27why, one step back23 render('chat.haml.html', {24 locals: {25 messages: messages26 }27 })Cleaning up example appvisionmediabefore adoption05e9cc6
line 28why, one step back28})Docsvisionmediabefore adoption5342d04
line 29why, one step back29Added chat example (though not practical over http)visionmediabefore adoption9c5552c
lines 30–36why, one step back30post('/chat', function(){31 messages.push(param('message'))32 halt(200)33})3435get('/chat/messages', function(){36 contentType('json')Added aliases of JSON.encode() and JSON.decode()visionmediabefore adoption0d9f502
line 37why, one step back37 return JSON.encode(messages)Docsvisionmediabefore adoption5342d04
lines 38–39why, one step back38})39More example app stylingvisionmediabefore adoptionbb2e79f
lines 40–50why, one step back40get('/public/:file', function(file){41 var path = dirname(__filename) + '/public/' + file42 require('path').exists(path, function(exists){43 if (!exists) halt()44 require('posix').cat(path).addCallback(function(content){45 contentType(path)46 halt(200, content)47 })48 })49})50Started show exceptions supportvisionmediabefore adoptione728d3c
lines 51–54why, one step back51get('/error', function(){52 throw new Error('oh noes!')53})54Docsvisionmediabefore adoption5342d04
line 55why, one step back55run()