-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
28 lines (20 loc) · 777 Bytes
/
main.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
const express = require("express");
const http = require("http");
const socketio = require("socket.io");
const path = require("path");
const Participant = require("./participant");
const PORT = process.env.PORT || 8080;
const PRODUCTION_MODE = process.env.NODE_ENV === "production";
const app = express();
const server = http.createServer(app);
const io = socketio(server);
app.use(express.static("public"));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname + "/public/index.html"));
});
// console.log that your server is up and running
server.listen(PORT, () => console.log(`Listening on port ${PORT} in ${PRODUCTION_MODE ? "production" : "debug"} mode`));
io.on("connection", socket => {
socket.emit("connected");
new Participant(io, socket);
});