-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (32 loc) · 916 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
31
32
33
34
35
36
37
38
39
const config = require('./utils/config')
const express = require('express')
require('express-async-errors')
const cors = require("cors")
const app = express()
const mongoose = require('mongoose')
const cookieParser = require('cookie-parser')
const middleware = require('./utils/middleware')
const userRouter = require('./routers/userRouter')
const noteRouter = require('./routers/noteRouter')
app.use(cookieParser())
app.use(express.json())
app.use(cors({
credentials: true,
}))
app.use(express.static('build'))
mongoose.connect(config.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
})
.then(result => {
console.log("Connected to MongoDB")
})
.catch((err) => {
console.error(err)
})
app.use('/auth', userRouter)
app.use('/notes', noteRouter)
app.use(middleware.errorHandler)
module.exports = app