This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (49 loc) · 2.18 KB
/
app.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
57
58
59
const express = require('express');
const app = express();
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const fs = require( 'fs' );
const config = require('./config/config');
const key = fs.readFileSync(config.key);
const cert = fs.readFileSync(config.cert);
const https = require('https').createServer({ key : key, cert : cert }, app);
const io = require('socket.io')(https);
// --------------------------------------------------------------------------------------
// disable express header
app.disable('x-powered-by')
// --------------------------------------------------------------------------------------
// view engine setup
app.set('views', __dirname + '/views');
app.set('view engine', 'pug');
// --------------------------------------------------------------------------------------
// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
// --------------------------------------------------------------------------------------
// Make io accessible to our router
app.use(function(req, res, next){
req.io = io;
next();
});
// --------------------------------------------------------------------------------------
io.on('connection', function(socket){
console.log('A new WebSocket connection has been established');
});
https.listen(8088, function() {
console.log('Listening on *:8088');
});
// --------------------------------------------------------------------------------------
// set up routes
app.use('/', require('./routes/index'));
app.use('/data', require('./routes/data')); // debug only
app.use('/terminal', require('./routes/terminal')); // debug only
// --------------------------------------------------------------------------------------
require('./log_processing')(io); // all the logic is done here
// --------------------------------------------------------------------------------------
module.exports = app;