-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
34 lines (26 loc) · 842 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
32
33
34
const express = require("express");
const mongoose = require("mongoose");
const { MONGODB_URL } = require("./config/keys");
const PORT = process.env.PORT || 8070;
const app = express();
app.use(express.json());
mongoose.connect(MONGODB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const connection = mongoose.connection;
connection.once("open", () => {
console.log("Mongodb Connection Success!");
})
require("./models/Student")
app.use(require("./routes/students"))
if (process.env.NODE_ENV == "production") {
app.use(express.static("react-quiz-app/build"));
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "react-quiz-app", "build", "index.html"));
});
}
app.listen(PORT, () => {
console.log(`server is up and running on port: ${PORT}`);
})