-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (16 loc) · 694 Bytes
/
Copy pathserver.js
File metadata and controls
22 lines (16 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const express = require("express");
const path = require("path");
const http = require("http");
const PeerDataServer = require("peer-data-server");
const PORT = parseInt(process.env.PORT, 10) || (process.env.NODE_ENV === "production" ? 8080 : 3001);
const app = express();
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, "build")));
app.get("*", (req, res) =>
res.sendFile(path.join(__dirname, "build", "index.html"))
);
}
const appendPeerDataServer = PeerDataServer.default || PeerDataServer;
const server = http.createServer(app);
appendPeerDataServer(server);
server.listen(PORT, () => console.log(`Server started at port ${PORT}`));