add body parser

This commit is contained in:
Jay 2019-12-18 14:16:19 +08:00
parent 39e6fd26fe
commit cc758fccf4

View File

@ -10,6 +10,7 @@ module.exports = server
// load middleware module
const koaLogger = require('koa-logger')
const koaCors = require('@koa/cors')
const koaBody = require('koa-body')
const rootRouter = require('@route/index.js')
app.use(koaLogger())
@ -18,5 +19,11 @@ app.use(koaCors({
// allow all origin
origin: ctx => ctx.get('origin')
}))
app.use(koaBody({
multipart: true,
formidable: {
maxFileSize: 100 * 1024 * 1024 // 100 mb
}
}))
app.use(rootRouter.allowedMethods())
app.use(rootRouter.routes())