-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
21 lines (17 loc) · 733 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const roomsRoute = require('./routes/rooms');
const bookingsRoute = require('./routes/bookings');
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use('/api/rooms', roomsRoute);
app.use('/api/rooms', bookingsRoute);
const urlToDatabase = "mongodb://127.0.0.1:27017/roomBooking";
mongoose.connect(urlToDatabase, {useNewUrlParser:true, useUnifiedTopology:true})
.then(()=> console.log('database connected...'))
.catch(err=>console.log('Program crashed on connecting to database!', err))
const port = process.env.PORT || 5001;
app.listen(port,()=>{
console.log(`${port} - port listening...`);
});