-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (21 loc) · 708 Bytes
/
Copy pathserver.js
File metadata and controls
25 lines (21 loc) · 708 Bytes
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
const express = require('express')
const bodyParser = require('body-parser')
const dbConfig = require('./config/database_config.js')
const mongoose = require('mongoose')
const app = express()
const port = process.env.PORT || 8000
app.use(bodyParser.urlencoded({ extended: true }))
mongoose.Promise = global.Promise
mongoose.connect(dbConfig.url, {
useNewUrlParser: true,
useFindAndModify: false
}).then(() => {
console.log('Successfully connected to the database')
}).catch(err => {
console.log('Could not connect to the database. Exiting now...', err)
process.exit()
})
require('./app/routes/todo_routes.js')(app)
app.listen(port, () => {
console.log(`We are live on ${port}`)
})