-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
47 lines (37 loc) · 1.21 KB
/
server.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
47
var matador = require('matador')
, env = process.env.NODE_ENV || 'development'
, argv = matador.argv
, config = require('./app/config/' + env)
, app = matador.createApp(__dirname, config, {})
, port = argv.port || process.env.PORT || 3000
// Register the matador cache helper.
app.registerHelper('Cache', matador.helpers.CacheHelper)
app.configure(function () {
app.set('view engine', 'html')
app.register('.html', matador.engine)
// Use the cache helper's no-cache middleware.
app.use(app.getHelper('Cache').auditHeadersMiddleware)
app.use(app.getHelper('Cache').noCacheMiddleware)
app.use(matador.cookieParser())
app.use(matador.session({secret: 'boosh'}))
// TODO: Add JSON body parser middleware
app.use(app.requestDecorator())
app.use(app.preRouter())
})
app.configure('development', function () {
app.use(matador.errorHandler({ dumpExceptions: true, showStack: true }))
app.set('soy options', {
eraseTemporaryFiles: true
, allowDynamicRecompile: true
})
})
app.configure('production', function () {
app.use(matador.errorHandler())
})
app.configure(function () {
app.use(app.router({}))
})
app.prefetch()
app.mount()
app.listen(port)
console.log('matador running on port ' + port)