app.js
940 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
let express = require('express')
let cookieParser = require('cookie-parser')
let cors = require('cors')
let corsConfig = require('./config/cors')
const indexRouter = require('./routes/index')
const authRouter = require('./routes/authRouter')
const userRouter = require('./routes/userRouter')
const dockerRouter = require('./routes/dockerRouter')
let app = express()
app.use(cors(corsConfig))
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(cookieParser())
app.use('/', indexRouter)
app.use('/', authRouter)
app.use('/', userRouter)
app.use('/', dockerRouter)
app.use(function(req, res) {
res.status(400)
res.json({
success: false,
message: 'error'
})
})
app.use(function(err, req, res) {
res.locals.message = err.message
res.locals.error = req.app.get('env') === 'development' ? err : {}
res.status(err.status || 500)
res.json({
success: false
})
})
module.exports = app