forked from nowmozillaclub/enrollar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (29 loc) · 838 Bytes
/
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
const express = require('express');
const mongoose = require('mongoose')
const { URI } = require('./keys/keys')
const bodyParser = require('body-parser')
const cors = require('cors')
const app = express();
app.use(cors());
// all middlewares
app.use( bodyParser.json() )
app.use(require('./routes/auth'))
app.use(require('./routes/courses'))
// connecting to the db here
options = {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify:false
}
mongoose.connect(URI, options)
// checking connections by adding an event listener
mongoose.connection.on('connected',()=>{
console.log("Connection went through!")
}).on('error',(err)=>{
console.log("An error occured!",err)
})
// listening on port
const PORT = process.env.PORT || 5000;
app.listen(PORT ,()=>{
console.log("Listening on Port",PORT)
});