-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (19 loc) · 739 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (19 loc) · 739 Bytes
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
//JS file for the SPA
// imports needed Node.js modules
const express = require("express");
const path = require("path");
const app = express();
app.use("/spa", express.static(path.resolve(__dirname,"spa"),
{extensions: ["js"]}));
app.use("/src", express.static(path.resolve(__dirname,"src")));
app.use("/images", express.static(path.resolve(__dirname,"images")));
app.get("/sw.js", (req, res) => {
res.sendFile(path.resolve(__dirname, "sw.js"));
});
app.get("/manifest.json", (req, res) => {
res.sendFile(path.resolve(__dirname, "manifest.json"));
});
app.get("/*", (req, res) => {
res.sendFile(path.resolve(__dirname,"index.html"));
});
app.listen(process.env.PORT || 5500, () => console.log("Server running..."));