forked from FirstLegoLeague/scoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalserver.js
42 lines (34 loc) · 1.47 KB
/
localserver.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
37
38
39
40
41
42
var express = require('express');
var app = express();
var utils = require('./server_modules/utils');
var fileSystem = require('./server_modules/file_system');
var args = require('./server_modules/args');
var views = require('./server_modules/views');
var configs = [require('./server_modules/slave_mode')];
var middlewareLayers = [express.static(fileSystem.resolve('/src')),
require('cookie-parser')(),
require('./server_modules/sessions').middleware,
require('./server_modules/auth').basic(args.basicAuthCreds),
require('./server_modules/cors').middleware,
require('./server_modules/cache').middleware,
require('./server_modules/body_builder').middleware,
require('./server_modules/log').middleware];
var routers = [views,
fileSystem,
require('./server_modules/sessions'),
require('./server_modules/teams'),
require('./server_modules/scores'),
require('./server_modules/challenges')];
configs.forEach(function(config) {
config.configure(app);
});
middlewareLayers.forEach(function(layer) {
app.use(layer);
});
routers.forEach(function(router) {
router.route(app);
});
app.listen(args.port, function() {
console.log('Listening on port ', args.port);
console.log('open browser to http://localhost:{0}/'.format(args.port));
});