const Koa = require('koa') const app = new Koa() const config = require('@config/index.js') const server = app.listen(config.server.port, () => { console.log(`server start on port ${server.address().port}`) }) 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()) app.use(koaCors({ credentials: true, // 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())