Skip to content
Myr

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 file

Take it

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

Added Profiler pluginvisionmediabefore adoption0a1ef27

line 1why, one step back
1

Cleaning up example appvisionmediabefore adoption05e9cc6

line 2why, one step back
2require.paths.unshift('lib')

Added Profiler pluginvisionmediabefore adoption0a1ef27

lines 3–5why, one step back
3require('express')
4require('express/plugins')5

Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51

line 6why, one step back
6configure(function(){

Cleaning up example appvisionmediabefore adoption05e9cc6

lines 7–8why, one step back
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)

Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51

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(){

Moved render() to Requestvisionmediabefore adoptione182388

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 })

Cleaning up example appvisionmediabefore adoption05e9cc6

line 27why, one step back
27})

Added Profiler pluginvisionmediabefore adoption0a1ef27

line 28why, one step back
28

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

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

Escaping sample chat app messagesvisionmediabefore adoptiond94ed67

line 30why, one step back
30 messages.push(escape(this.param('message')))

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)

Added Profiler pluginvisionmediabefore adoption0a1ef27

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

Make route params request specificvisionmediabefore adoptiond0dae12

line 46why, one step back
46get('/public/:file', 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

Started show exceptions supportvisionmediabefore adoptione728d3c

lines 50–53why, one step back
50get('/error', function(){
51 throw new Error('oh noes!')52})53

Added Profiler pluginvisionmediabefore adoption0a1ef27

line 54why, one step back
54run()