-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
21 lines (16 loc) · 838 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const app = new (require('koa'))()
app.use(require('koa-body')({multipart: true}))
app.use(require('koa2-cors')())
app.use(require('./src/middleware/init/log'))
app.use(require('./src/middleware/init/ok'))
if (process.env.NODE_ENV !== 'prod') app.use(require('./src/middleware/reqTimer'))
app.use(require('./src/middleware/errorHandler'))
app.use(require('./src/middleware/paramHandler'))
app.use(require('./src/middleware/loginUserHandler'))
app.use(require('./src/middleware/loginBbHandler'))
app.use(require('./src/router').routes()).use(require('./src/router').allowedMethods())
const config = require('./config/env')
const server = app.listen(config.server.port)
require('./src/log/realtime').init(app.listen(config.server.log.port))
const mongoose = require('mongoose')
mongoose.connect(config.db.host, {useNewUrlParser: true})