-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
23 lines (18 loc) · 811 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require("express");
const path = require("path");
const { getConfig } = require("./server/config");
const errorHandler = require("./server/middlewares/error-handler");
const { SERVER_PORT } = getConfig();
const app = express();
app.use(express.json({ extended: true }));
app.use("/api/area", require("./server/routes/area.routes"));
app.use("/api/zone", require("./server/routes/zone.routes"));
app.use("/api/grid", require("./server/routes/grid.routes"));
if (process.env.NODE_ENV === "production") {
app.use("/", express.static(path.join(__dirname, "build")));
app.get("*", (req, res) => {
res.send(path.resolve(__dirname, "build", "index.html"));
});
}
app.use(errorHandler);
app.listen(SERVER_PORT, () => console.log(`App has been started on port ${SERVER_PORT}`));