-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (26 loc) · 1.05 KB
/
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
32
33
const express = require("express");
const app = express();
const path = require("path");
const mongoose = require("mongoose");
const PORT = process.env.PORT || 3001;
const { Projects, Users, Tickets } = require("./Routes/index.js");
// mongoose.connect(`mongodb+srv://herokuUser:${process.env.herokuPass}@cluster0.beusi.mongodb.net/`, { useNewUrlParser: true, useUnifiedTopology: true }, () => {
// console.log("Successfully connected to Database");
// });
mongoose.connect(`mongodb://localhost:27017/bugTracker`, { useNewUrlParser: true, useUnifiedTopology: true }, () => {
console.log("Successfully connected to Database");
});
app.use(express.json());
app.use(express.static("public"));
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, 'frontEnd/build')));
}
app.use("/api", Projects);
app.use("/api", Users);
app.use("/api", Tickets);
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "./frontEnd/public/index.html"));
});
app.listen(PORT, () => {
console.log(`listening on ${PORT}`)
});