-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
51 lines (29 loc) · 882 Bytes
/
server.js
File metadata and controls
51 lines (29 loc) · 882 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const bodyParser = require('body-parser');
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const app = express();
const PORT = 8060;
//import routes
const postBin = require('./routes/postBin');
//app middelware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(express.json());
app.use(cors());
//routes middelware
app.use(postBin);
app.get("/",(req,res)=>{
res.send("upload file")
})
const DB_URL='mongodb+srv://dev:Mng77@mernapp.zwstxds.mongodb.net/PostBin?retryWrites=true&w=majority'
mongoose.set('strictQuery', false);
mongoose.set('strictQuery', true);
mongoose.connect(DB_URL)
.then(()=>{
console.log('DB Connected');
})
.catch((err)=> console.log('DB connection error',err));
app.listen(PORT,()=>{
console.log(`App is running on ${PORT}`);
})