-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (26 loc) · 908 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
35
36
37
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const postRoutes = require('./routes/posts');
app.use(bodyParser.json());
app.use(cors());
//calling routes
app.use(postRoutes);
//defining port
const PORT =8000;
const DB_URL ='mongodb+srv://itp-sliit:itp123@sllit.empkt.mongodb.net/itp-sliit?retryWrites=true&w=majority';
//const DB_URL='mongodb+srv://sliit:sliit123@itpcluster.fpcc4.mongodb.net/furnitureDB?retryWrites=true&w=majority';
//checking the connection of database
mongoose.connect(DB_URL,{
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(()=>{
console.log('DB is connected');
})
.catch((err)=>console.log('DB connection err',err));
app.listen(PORT, ()=>{
console.log(`App is running on ${PORT}`);
});