forked from CodoSapiens-HACKNITP/PRECycle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (27 loc) · 927 Bytes
/
server.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
const express = require("express");
const app = express();
const connectDB = require("./config/db");
var cors = require("cors");
//connect database
connectDB();
//Init Middleware
app.use(express.json({ extended: false }));
app.use(cors());
//define routes
app.use("/feedback", require("./routes/feedback"));
app.use("/users", require("./routes/users"));
app.use("/auth", require("./routes/auth"));
app.use("/seller", require("./routes/seller"));
app.use("/rider", require("./routes/rider"));
app.use("/vendor", require("./routes/vendor"));
//Heroku deploy code
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
}
//run the server
const port = process.env.PORT || 1210;
app.listen(port, () => console.log(`Server started on port ${port}`));