forked from taylonr/async-programming-promises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (36 loc) · 1.17 KB
/
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
33
34
35
36
37
38
39
40
41
const jsonServer = require("json-server");
const express = require("express");
const path = require("path");
const server = jsonServer.create();
const router = jsonServer.router("./data/db.json");
const middlewares = jsonServer.defaults();
server.use(middlewares);
server.get("/orderStatuses", (req, res, next) => {
setTimeout(() => {
next();
}, 1500);
});
server.use("/src", express.static(__dirname + "/src/"));
server.use("/home", (req, res) => {
res.sendFile(path.join(__dirname + "/index.html"));
});
server.use("/understanding", (req, res) => {
res.sendFile(path.join(__dirname + "/understanding.html"));
});
server.use("/consuming", (req, res) => {
res.sendFile(path.join(__dirname + "/consuming.html"));
});
server.use("/creating", (req, res) => {
res.sendFile(path.join(__dirname + "/creating.html"));
});
server.use("/iterating", (req, res) => {
res.sendFile(path.join(__dirname + "/iterating.html"));
});
server.use("/service-worker.js", (req, res) =>
res.sendFile(path.join(__dirname + "/service-worker.js"))
);
server.use(router);
const port = process.env.PORT || 3000
server.listen(port, () => {
console.log(`JSON Server is running on port ${port}`);
});