-
Notifications
You must be signed in to change notification settings - Fork 0
/
server-dashboard.js
45 lines (29 loc) · 998 Bytes
/
server-dashboard.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
41
42
43
44
45
const express= require('express');
const mongoose= require('mongoose');
const morgan= require('morgan');
const path= require('path');
const cors =require('cors');
const app=express();
const PORT=process.env.PORT || 8000;
//http://localhost:8000
const routes=require('./Routes/api');
const routes1=require('./Routes/api1');
const routes2=require('./Routes/api2');
const MONGODB_URI='mongodb+srv://nivesh:[email protected]/myFirstDatabase?retryWrites=true&w=majority';
//|| 'mongodb://localhost/mern_youtube'
mongoose.connect(MONGODB_URI , {
useNewUrlParser: true,
useUnifiedTopology: true
});
mongoose.connection.on('connected', () => {
console.log('Mongoose is connected!!!!');
});
// Data parsing
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cors());
app.use(morgan('tiny'));
app.use('/api',routes);
app.use('/api1',routes1);
app.use('/api2',routes2);
app.listen(PORT,console.log(`Server is starting at ${PORT}`));