-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (27 loc) · 1.04 KB
/
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
24
25
26
27
28
29
30
31
32
33
34
require("dotenv").config();
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const path = require("path");
const connectDB = require("./config/db");
const tableDataRoutes = require("./routes/tableDataRoutes");
const userRoutes = require("./routes/userRoutes");
const organizationRoutes = require("./routes/organizationRoutes");
const groupRoutes = require("./routes/groupRoutes");
const typeRoutes = require("./routes/typesRoutes");
connectDB();
const port = process.env.PORT || 80;
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use("/", userRoutes);
app.use("/", organizationRoutes);
app.use("/", groupRoutes);
app.use("/", tableDataRoutes);
app.use("/", typeRoutes);
app.use(express.static(path.resolve(__dirname, "client", "build")));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
app.listen(port, () => console.log(`Server running on port ${port}`));