forked from IFS49F/poker-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (26 loc) · 976 Bytes
/
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
const express = require('express');
const app = express();
const http = require('http').Server(app);
const clientOrigin = process.env.CLIENT_ORIGIN || '*:*';
const io = require('socket.io')(http, {
origins: clientOrigin,
serveClient: false,
pingInterval: 5000,
pingTimeout: 15000
});
const port = process.env.PORT || 4000;
process.on('uncaughtException', (err) => {
console.error('There was an uncaught error:', err);
process.exit(1); // Exit the process with failure
});
// Handle unhandled promise rejections
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
process.exit(1); // Exit the process with failure
});
app.use(express.static(__dirname + '/public'));
io.on('connection', (socket) => require('./app/socket')(socket, io));
http.listen(port, () => console.log(`Listening on port ${port}`));
app.use((req, res) => {
res.sendFile(__dirname + '/public/index.html');
});