-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
56 lines (45 loc) · 1.56 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Create App, HTTP, ATEM and io
var express = require('express');
var logger = require('morgan');
var path = require('path');
var colour = require('colour');
var fs = require('fs');
var app = express();
var http = require('http').Server(app);
var PORT = 3000;
// Log all requests in server output
// app.use(logger('dev'));
app.use(function (req, res, next) {
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');
next();
});
// Static route for static requests
app.use(express.static(path.join(__dirname, 'public')));
// Route for Config
var configurationAPIRouter = require('./lib/configuration-api-router');
app.use('/config/api', configurationAPIRouter);
// Route for Client Info API
var clientAPIRouter = require('./lib/client-api-router');
app.use('/clients/api', clientAPIRouter);
// Route for Role API
var rolesAPIRouter = require('./lib/roles-api-router');
app.use('/roles/api', rolesAPIRouter);
// Route for /
app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/handshake.html');
});
// Set server to listen
http.listen(PORT, function() {
console.log('HTTP Server Listener Started:'.bold, PORT);
});
// Run all modules defined in modules.js
var modules = require('./modules')(http);
process.on('SIGINT', function() {
fs.unlink(__dirname + '/lib/database/connected-clients.db', function(err) {
if (err) throw err;
console.log('Deleted'.red.bold, __dirname + '/lib/database/connected-clients.db');
process.exit();
});
});