-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.coffee
32 lines (23 loc) · 951 Bytes
/
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
express = require 'express'
engines = require 'consolidate'
routes = require './routes'
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.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.bodyParser()
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()
app.get '/', routes.index(config)
callback(server)