-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (23 loc) · 768 Bytes
/
Copy pathserver.js
File metadata and controls
29 lines (23 loc) · 768 Bytes
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
const express = require("express");
const mongoose = require("mongoose");
const PORT = process.env.PORT || 8080;
const app = express();
const path = require('path')
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static("client/build"));
mongoose.connect(process.env.MONGODB_URI ? process.env.MONGODB_URI : "mongodb://localhost:27017/petHotel_db", {
useNewUrlParser: true,
useFindAndModify: false,
useUnifiedTopology: true
});
console.log("DIRNAME PATH", __dirname)
// routes
app.use(require(path.join(__dirname, "app/routes/api.js")));
app.get("*",function(req,res){
res.sendFile(path.join(__dirname, "client/build/index.html")
)
})
app.listen(PORT, () => {
console.log(`App running on port ${PORT}!`);
});