-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (34 loc) · 1.07 KB
/
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
33
34
35
36
37
38
39
40
const express = require("express")
const mongoose = require("mongoose")
const dotenv = require("dotenv")
const bodyParser = require("body-parser");
const cors = require("cors")
const path = require("path")
dotenv.config({ path: ".env" })
const port = process.env.PORT || 4000
const DB_HOST = process.env.DB_HOST
mongoose.connect("mongodb+srv://trast_app:[email protected]/trast", {
useFindAndModify: false,
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
})
const app = express();
app.use(express.static(path.join(__dirname, 'build')));
app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors())
app.use("/api", require("./server/routes/product"))
app.get('*', (req,res) =>{
res.sendFile(path.join(__dirname+'/build/index.html'));
});
/*mongoose.connect(DB_HOST,
{
useFindAndModify: false,
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
}
)*/
app.listen(port, () => console.log(`Connect port ${port}`))