-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
32 lines (26 loc) · 877 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
const express = require('express')
const app = express()
const cors = require('cors')
const mongoose = require('mongoose')
const config = require('./utils/config')
const middleware = require('./utils/middleware')
const authRouter = require('./controllers/auth')
const dashboardRouter = require('./controllers/dashboard')
const roomRouter = require('./controllers/room')
const codeRouter = require('./controllers/code')
mongoose.connect(config.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
app.use(cors())
app.use(express.json())
if (process.env.NODE_ENV === 'development') {
app.use(middleware.requestLogger)
}
app.use('/api/auth', authRouter)
app.use('/api/dashboard', dashboardRouter)
app.use('/api/rooms', roomRouter)
app.use('/api/code', codeRouter)
app.use(middleware.unknownEndpoint)
app.use(middleware.errorHandler)
module.exports = app