npm-package/utils/impl/koaresp.js
2020-11-12 17:23:54 +08:00

19 lines
445 B
JavaScript

'use strict';
const Moment = require('moment');
function ctxresp(ctx, data, errno, errmsg) {
if (errno === null || errno === undefined) errno = 0;
if (errmsg === null || errmsg === undefined) errmsg = '';
if (data === null || data === undefined) data = {};
ctx.body = {
code: errno,
msg: errmsg,
data: data,
stime: Moment().format('YYYY-MM-DD HH:mm:ss SSS')
};
}
module.exports = ctxresp;