Skip to content
Myr

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 file

Take 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 back
1

Cleaning up example appvisionmediabefore adoption05e9cc6

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

Refactored Collection#keys() with #map()visionmediabefore adoptionf421443

line 3why, one step back
3require('express')

Added plugins.js for quick plugin mixinsvisionmediabefore adoption39b0e43

line 4why, one step back
4require('express/plugins')

Refactored Collection#keys() with #map()visionmediabefore adoptionf421443

line 5why, one step back
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

line 10why, one step back
10 set('root', dirname(__filename))

Added "helpful 404" support pagevisionmediabefore adoption897c590

line 11why, one step back
11 enable('helpful 404')

Added "show exceptions" setting and specsvisionmediabefore adoptiondad297e

line 12why, one step back
12 enable('show exceptions')

Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51

lines 13–15why, one step back
13 enable('cache views')
14})15

Make route params request specificvisionmediabefore adoptiond0dae12

lines 16–18why, one step back
16var messages = [],
17 path = require('path'),18 posix = require('posix')

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

line 19why, one step back
19

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

line 20why, one step back
20get('/', function(){

Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764

line 21why, one step back
21 this.redirect('/chat')

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

lines 22–23why, one step back
22})
23

Started chat examplevisionmediabefore adoption654c526

line 24why, one step back
24get('/chat', function(){

Moved render() to Requestvisionmediabefore adoptione182388

line 25why, one step back
25 this.render('chat.haml.html', {

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

lines 26–29why, one step back
26 locals: {
27 messages: messages28 }29 })

Cleaning up example appvisionmediabefore adoption05e9cc6

line 30why, one step back
30})

Refactored Collection#keys() with #map()visionmediabefore adoptionf421443

line 31why, one step back
31

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

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

Moved render() to Requestvisionmediabefore adoptione182388

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

Evaulating routes in context to their given request instancevisionmediabefore adoption0f3a764

line 34why, one step back
34 this.halt(200)

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

lines 35–37why, one step back
35})
3637get('/chat/messages', function(){

Long-polling chat example appvisionmediabefore adoptionb75e1ee

lines 38–46why, one step back
38 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 back
47})
48

Make route params request specificvisionmediabefore adoptiond0dae12

line 49why, one step back
49get('/public/:file', function(file){

Moved render() to Requestvisionmediabefore adoptione182388

lines 50–58why, one step back
50 var self = this
51 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 back
59})
60

Started show exceptions supportvisionmediabefore adoptione728d3c

lines 61–64why, one step back
61get('/error', function(){
62 throw new Error('oh noes!')63})64

Refactored Collection#keys() with #map()visionmediabefore adoptionf421443

line 65why, one step back
65run()