-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 919 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
const express = require("express");
const cors = require("cors");
require("dotenv").config();
const app = express();
const port = process.env.PORT || 3000;
const db = require("./config/mongoose");
const path = require("path");
app.use(cors());
app.use(express.json());
app.use("/", require("./routes/index"));
app.get('/', (req,res) => {
res.send("Server is Connected");
})
// only for deployment
// if (process.env.NODE_ENV === "production") {
// // app.use(express.static("build"));
// app.use(express.static(path.join(__dirname, "client", "build")));
// app.get("*", (req, res) => {
// res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
// });
// }
module.exports = app.listen(port, function (err) {
if (err) {
console.log(`Error in running the server ${err}`);
} else {
console.log(`Server is up and running on port ${port}`);
}
});