-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDS.js
More file actions
47 lines (38 loc) · 1.47 KB
/
Copy pathDS.js
File metadata and controls
47 lines (38 loc) · 1.47 KB
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
const express = require("express");
const app = express();
const fs = require("fs");
const path = require('path');
const conf = require("config");
const server = require('http').Server(app);
const logic = require('./logic');
const io = conf.config.useSSL
? require('socket.io')(https.createServer({
key: fs.readFileSync(conf.config.sslkey),
cert: fs.readFileSync(conf.config.sslCert)
}, app))
: require('socket.io')(server);
const sslServer = conf.config.useSSL
? https.createServer({
key: fs.readFileSync(conf.config.sslkey),
cert: fs.readFileSync(conf.config.sslCert)
}, app)
: null;
logic.setVars(io);
app.set("view engine", "ejs");
app.use(express.static(path.join(__dirname, 'public')));
if (conf.config.useSSL) {
app.use(logic.requireHTTPS);
}
app.get('/', (req, res) => res.render('content'));
io.on('connection', (socket) => logic.handleSocketConnection(socket, conf.config));
setInterval(() => logic.UpdateContent(conf.config), conf.config.scanIntervall * 1000);
if (conf.config.useZipDownload) {
console.log(`Using ${conf.config.zipURL}`)
logic.DownloadZipFile(conf.config);
setInterval(() => logic.DownloadZipFile(conf.config), conf.config.zipDownloadIntervall * 1000);
}
server.listen(conf.config.httpPort, () => console.log(`Listening on port ${conf.config.httpPort} via http`));
if (conf.config.useSSL) {
const sslPort = conf.config.sslPort;
sslServer.listen(sslPort, () => console.log(`Listening on port ${sslPort} via https`));
}