1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 1x 61x 53x 53x 53x 52x 1x 1x 53x 53x | const body = require('koa-body'); module.exports = function (options) { return async function (ctx, next) { await body(options)(ctx, function () { return new Promise((resolve, reject) => { if (!ctx.request.body.files) { ctx.post = ctx.request.body; } else { ctx.post = ctx.request.body.fields; ctx.file = ctx.request.body.files; } resolve(true); }); }); await next(); } }; |