Skip to content
Myr

app.js

This file

Path

examples/app.js

55 lines · 971 bytes · JavaScript

Last changed by

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

History of this file

Take it

The walk stopped after 200 commits: lines older than 5342d04 point at it.

Docsvisionmediabefore adoption5342d04

line 1why, one step back
1

Cleaning up example appvisionmediabefore adoption05e9cc6

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

Docsvisionmediabefore adoption5342d04

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

Added plugins.js for quick plugin mixinsvisionmediabefore adoption39b0e43

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

Docsvisionmediabefore adoption5342d04

line 5why, one step back
5

Defaulting views to <root>/viewsvisionmediabefore adoption84a7c51

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

When Accept includes text/html display exceptions otherwise 500visionmediabefore adoptionbd4f150

line 7why, one step back
7 use(CommonLogger)

Cleaning up example appvisionmediabefore adoption05e9cc6

lines 8–9why, one step back
8 use(MethodOverride)
9 use(ContentLength)

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

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

lines 16–17why, one step back
16var messages = []
17

CommonLogger showing "/" as rootvisionmediabefore adoption2b02305

lines 18–21why, one step back
18get('/', function(){
19 redirect('/chat')20})21

Started chat examplevisionmediabefore adoption654c526

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

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

lines 23–27why, one step back
23 render('chat.haml.html', {
24 locals: {25 messages: messages26 }27 })

Cleaning up example appvisionmediabefore adoption05e9cc6

line 28why, one step back
28})

Docsvisionmediabefore adoption5342d04

line 29why, one step back
29

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

lines 30–36why, one step back
30post('/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 back
37 return JSON.encode(messages)

Docsvisionmediabefore adoption5342d04

lines 38–39why, one step back
38})
39

More example app stylingvisionmediabefore adoptionbb2e79f

lines 40–50why, one step back
40get('/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})50

Started show exceptions supportvisionmediabefore adoptione728d3c

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

Docsvisionmediabefore adoption5342d04

line 55why, one step back
55run()