-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (23 loc) · 830 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
const express = require('express')
const mongoose = require('mongoose')
const passport = require('passport')
const bodyParser = require('body-parser')
const authRoutes = require('./routes/auth')
const cors = require('cors')
const morgan = require('morgan')
const keys = require('./config/keys')
const app = express()
mongoose.set('useNewUrlParser', true);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.connect(keys.mongoURI, { useNewUrlParser: true })
.then(() => console.log('MongoDB connected.'))
.catch(error => console.log(error))
app.use(passport.initialize())
require('./middleware/passport')(passport)
app.use(morgan('dev'))
app.use(cors())
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json())
app.use('/api/auth', authRoutes)
module.exports = app