-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
35 lines (30 loc) · 967 Bytes
/
app.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
const express = require("express");
const config = require("config");
const path = require("path");
const mongoose = require("mongoose");
const app = express();
app.use(express.json({ extended: true }));
app.use("/api/auth", require("./routes/auth.routes"));
app.use("/api/tables", require("./routes/tables.routes"));
app.use("/api/table", require("./routes/table.routes"));
//!!
app.use(express.static(path.join(__dirname, "client/build")));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
//!!
const PORT = process.env.PORT || 5000;
async function start() {
try {
await mongoose.connect(config.get("mongoURI"), {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
});
app.listen(PORT, () => console.log("App has been started on port " + PORT));
} catch (error) {
console.log("Server Error", error.message);
process.exit(1);
}
}
start();