-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 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
const express = require("express");
const cors = require("cors");
const app = express();
const PORT = process.env.PORT || 5000;
const path = require("path");
// middleware
app.use(express.json());
app.use(cors());
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, "frontend/build")));
}
app.listen(PORT, () => {
console.log(`Server running on port: ${PORT}`);
});
app.use("/auth", require("./routes/auth"));
app.use("/project", require("./routes/project"));
app.use("/user", require("./routes/user"));
app.use("/field", require("./routes/field"));
app.use("/skill", require("./routes/skill"));
app.use("/tag", require("./routes/tag"));
app.use("/application", require("./routes/application"));
app.use("/member", require("./routes/member"));
app.use("/invite", require("./routes/invite"));
app.use("/task", require("./routes/task"));
app.use("/commit", require("./routes/commit"));
app.use("/answer", require("./routes/answer"));
app.use("/notification", require("./routes/notification"));
if (process.env.NODE_ENV === "production") {
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "frontend/build", "index.html"));
});
}