update
This commit is contained in:
15
utils/impl/koaresp.js
Normal file
15
utils/impl/koaresp.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
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 = {
|
||||
result: errno === 0 ? 'ok' : 'fail',
|
||||
error: { code: errno, msg: errmsg },
|
||||
data: data
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = ctxresp;
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
module.exports = {
|
||||
prxrmq: require('./impl/prxrmq')
|
||||
prxrmq: require('./impl/prxrmq'),
|
||||
ctxresp: require('./impl/koaresp')
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ehason/utils",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Utils for ehason develope",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user