UNPKG

koa-body-res

Version:
18 lines (17 loc) 495 B
module.exports = function () { return function *koaRes(next) { try { yield* next; if (this.data != undefined || this.msg != undefined || this.go != undefined) { this.body = { data: this.data || '', msg: this.msg || '', go: this.go || '' }; this.body.code = this.status; } } catch (err) { throw err; } }; };