forked from codecombat/codecombat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.coffee
28 lines (24 loc) · 824 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
do (setupLodash = this) ->
GLOBAL._ = require 'lodash'
_.str = require 'underscore.string'
_.mixin _.str.exports()
express = require 'express'
http = require 'http'
log = require 'winston'
serverSetup = require './server_setup'
co = require 'co'
config = require './server_config'
Promise = require 'bluebird'
module.exports.startServer = (done) ->
app = createAndConfigureApp()
httpServer = http.createServer(app).listen app.get('port'), -> done?()
log.info('Express SSL server listening on port ' + app.get('port'))
{app, httpServer}
createAndConfigureApp = module.exports.createAndConfigureApp = ->
app = express()
if config.forceCompression
compression = require('compression')
app.use(compression())
serverSetup.setExpressConfigurationOptions app
serverSetup.setupMiddleware app
app