-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
57 lines (46 loc) · 1.23 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
57
'use strict';
// ############### web server by express
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const helmet = require('helmet');
const morgan = require('morgan');
const path = require('path');
const state = require('./modules/state');
let server;
if (process.env.HTTPS === 'yes') {
const fs = require('fs');
const options = {
key: fs.readFileSync('./ssl/key.pem'),
cert: fs.readFileSync('./ssl/cert.pem'),
};
server = require('https').createServer(options, app);
} else {
server = require('http').Server(app);
}
app.set('trust proxy', 1);
app.use(bodyParser.json({ type: '*/*', limit: '10000kb' }));
//modules
const routes = require('./modules/routes');
const chat = require('./modules/chat');
const chatVideo = require('./modules/chatVideo');
const sse = require('./modules/sse');
//static files
app.use(
'/static',
express.static(path.join(__dirname, '/client/build/static'), {
maxAge: 86400000,
}),
);
// security
app.use(helmet());
//logs
app.use(morgan('combined'));
// modules
// mind the sequence because of react router
sse(app, state);
chat(server);
routes(app, state);
chatVideo(server);
server.listen(8000);
console.log('+++ codeboohay +++ 8000');