koa-body-res
Version:
koa body router
18 lines (17 loc) • 495 B
JavaScript
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;
}
};
};