-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
30 lines (22 loc) · 907 Bytes
/
app.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
const express = require('express')
const bodyParser = require('body-parser')
const listEndPoints = require('express-list-endpoints')
const app = express()
app.use(bodyParser.urlencoded({extended : true}))
app.use(bodyParser.json())
const dbConfig = require('./Config/database.config.js')
const mongoose = require('mongoose')
mongoose.Promise = global.Promise
mongoose.connect(dbConfig.url).then(() => {
console.log("Successfully connected to the database")
}).catch(error => {
console.log(error)
console.log('Could not connect to the database. Exiting now...')
})
app.get('/', function(req, res) {
res.json({message: "Welcome to Student's Info application. Create, update, fetch and delete student using MongoDB", endPoints: listEndPoints(app)})
})
require('./App/Routers/student.router.js')(app)
app.listen(3000, function() {
console.log("Server is listening on port 3000")
})