This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.coffee
61 lines (52 loc) · 1.71 KB
/
server.coffee
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
express = require 'express'
engines = require 'consolidate'
childProc = require 'child_process'
packJson = require './package.json'
bowJson = require './bower.json'
exports.startServer = (config, callback) ->
port = process.env.PORT or config.server.port
app = express()
server = app.listen port, ->
console.log "Express server listening on port %d in %s mode", server.address().port, app.settings.env
app.configure ->
app.set 'port', port
app.set 'views', config.server.views.path
app.locals.basedir = config.server.views.path
app.engine config.server.views.extension, engines[config.server.views.compileWith]
app.set 'view engine', config.server.views.extension
app.use express.favicon()
app.use express.urlencoded()
app.use express.methodOverride()
app.use express.compress()
app.use config.server.base, app.router
app.use express.static(config.watch.compiledDir)
app.configure 'development', ->
app.use express.errorHandler()
options =
cachebust: if process.env.NODE_ENV isnt "production" then "?b=#{(new Date()).getTime()}" else ''
optimize: config.isOptimize ? false
appType: 'app'
packJson: packJson
reload: config.liveReload.enabled
app.get '/', (req, res) ->
options.page = 'index'
res.render 'index', options
app.get '/info', (req, res) ->
options.page = 'info'
options.node = {
'version': 'unknown'
}
options.npm = {
'version': 'unknown',
'modules': {}
}
options.mimosa = {
'version': 'unknown',
'modules': {}
}
options.bower = {
'version': 'unknown',
'modules': {}
}
res.render 'info', options
callback(server)