-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (25 loc) · 785 Bytes
/
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
// app.js
const express = require('express');
const app = express();
var cors = require('cors');
const SocketService = require("./services/SocketService");
const dotenv = require('dotenv');
dotenv.config();
// Set up express to parse JSON
app.use(express.json());
// Enable CORS for all routes
app.use(cors())
app.get('/', (req, res) => {
console.log('App connected')
res.send("App running")
});
// Start server
const PORT = process.env.PORT || 3001;
const server = app.listen(PORT, () => {
console.log("Server listening on port: ", PORT);
const socketService = new SocketService();
// We are going to pass server to socket.io in SocketService.js
socketService.attachServer(server);
});
server.keepAliveTimeout = 120 * 1000;
server.headersTimeout = 120 * 1000;