-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (33 loc) · 1.21 KB
/
server.js
File metadata and controls
41 lines (33 loc) · 1.21 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
// ====================
// Modules
// ====================
// NPM Modules
const express = require('express'); // Web Server Framework
const cors = require('cors'); // Cross-origin Access
const cookieParser = require('cookie-parser'); // Headers Cookies
const path = require('path');
// ====================
// Start Express Server
// ====================
require('dotenv').config();
const app = express();
const port = process.env.PORT || 8888;
app.use(express.static(path.join(__dirname, 'public')))
.use(cors())
.use(cookieParser())
.use(express.urlencoded({ extended: true, limit: '20mb' }))
.use(express.json({ limit: '20mb' }));
// Set the view engine to ejs
app.set('view engine', 'ejs');
const server = app.listen(port, () => {
require('dns').lookup(require('os').hostname(), function (err, ipv4) { // Log the URL to the host
err ? console.log(err) : console.log(
'Hosting Locally @ http://localhost' + ':' + port + '\nHosting Remotely @ http://' + ipv4 + ':' + port
);
});
require("./src/scripts/routes/routes")(app);
// Start WebSocket
const io = require('socket.io')(server);
const webSocket = require('./src/scripts/webSocket');
webSocket.init(io);
});