forked from FirstLegoLeague/scoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalserver.js
42 lines (37 loc) · 1.7 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 auth = require('./server_modules/auth');
var bodyParser = require('body-parser');
var log = require('./server_modules/log');
var configs = [require('./server_modules/slave_mode'), log];
var middlewares = [express.static(fileSystem.resolve('src')),
require('cookie-parser')(),
bodyParser.urlencoded({ extended: true }),
bodyParser.json(),
utils.middleware,
require('./server_modules/sessions').middleware,
auth.initialize(),
auth.session(),
auth.middleware,
require('./server_modules/cors').middleware,
require('./server_modules/cache').middleware];
var routers = [views,
auth,
fileSystem,
require('./server_modules/sessions'),
require('./server_modules/teams'),
require('./server_modules/settings'),
require('./server_modules/stages'),
require('./server_modules/scores'),
require('./server_modules/challenges')];
configs.forEach(config => config.configure(app));
middlewares.forEach(layer => app.use(layer));
routers.forEach(router => router.route(app));
app.listen(args.port, function() {
log.log.info(`Listening on port ${args.port}`);
log.log.info(`open browser to http://localhost:${args.port}/`);
});