-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 967 Bytes
/
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
const express = require("express");
const app = express();
const dotenv = require("dotenv");
const connectDb = require("./config/connectDb");
app.use(express.json());
// dotenv config
dotenv.config();
connectDb();
// routes
const userRoute = require("./routes/userRoute");
const projectRoute = require("./routes/projectRoute");
const taskRoute = require("./routes/taskRoute");
const notificationRoute = require("./routes/notificationRoute");
app.use("/api/users", userRoute);
app.use("/api/projects", projectRoute);
app.use("/api/tasks", taskRoute);
app.use("/api/notifications", notificationRoute);
// deployment config
const path = require("path");
app.use(express.static(path.join(__dirname, "./client/build")));
app.get("*", function (req, res) {
res.sendFile(path.join(__dirname, "./client/build/index.html"));
});
// port
const port = process.env.PORT || 4001;
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});