forked from codecombat/codecombat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (32 loc) · 1.17 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
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
(function(setupLodash) {
global._ = require('lodash');
_.str = require('underscore.string');
return _.mixin(_.str.exports());
})(this);
const express = require('express');
const http = require('http');
const serverSetup = require('./server_setup');
const co = require('co');
const config = require('./server_config');
const Promise = require('bluebird');
module.exports.startServer = function(done) {
const app = createAndConfigureApp();
const httpServer = http.createServer(app).listen(app.get('port'), () => typeof done === 'function' ? done() : undefined);
console.info('Express SSL server listening on port ' + app.get('port'));
return {app, httpServer};
};
var createAndConfigureApp = (module.exports.createAndConfigureApp = function() {
const app = express();
if (config.forceCompression) {
const compression = require('compression');
app.use(compression());
}
serverSetup.setExpressConfigurationOptions(app);
serverSetup.setupMiddleware(app);
return app;
});