codecombat/server.coffee

29 lines
761 B
CoffeeScript
Raw Normal View History

require 'newrelic' if process.env.NEW_RELIC_LICENSE_KEY?
2014-01-27 18:36:35 -05:00
do (setupLodash = this) ->
GLOBAL._ = require 'lodash'
_.str = require 'underscore.string'
_.mixin _.str.exports()
express = require 'express'
http = require 'http'
2014-02-04 17:08:20 -05:00
log = require 'winston'
2014-01-27 18:36:35 -05:00
serverSetup = require './server_setup'
2014-01-03 13:32:13 -05:00
module.exports.startServer = (done) ->
2014-01-27 18:36:35 -05:00
app = createAndConfigureApp()
http.createServer(app).listen app.get('port'), -> done?()
2014-06-30 22:16:26 -04:00
log.info('Express SSL server listening on port ' + app.get('port'))
app
2014-01-03 13:32:13 -05:00
2014-01-27 18:36:35 -05:00
createAndConfigureApp = ->
serverSetup.setupLogging()
serverSetup.connectToDatabase()
serverSetup.setupMailchimp()
app = express()
serverSetup.setExpressConfigurationOptions app
serverSetup.setupMiddleware app
serverSetup.setupRoutes app
app