-
Notifications
You must be signed in to change notification settings - Fork 12
/
app.js
46 lines (38 loc) · 894 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var Picard = require('../../lib/picard')
// Break CommonJS standards and copy
// functions from Picard into global namespace.
// Functions from routing.js include
// REST verbs, helpers, and routeSet
Picard.globalize()
get('/', function(){
return { text: 'Hello Universe' }
})
post('/order', function(){
return { text: 'Tea, Earl Grey, Hot' }
})
get('/haml', function(){
return {
template: 'index',
printDate: function () {
return (new Date()).toDateString();
},
currentUser: {
name: "Jean-Luc Picard",
bio: "Captain of the USS Enterprise"
}
}
})
var commands = [
{ command: 'Make it so' },
{ command: 'You have the bridge, Number One' }
]
get('/json', function(){
return {
type: 'application/json',
body: JSON.stringify(commands)
}
})
get('/redirect/?', function(request){
request.redirect('/haml')
})
Picard.start()