ctxresp add stime

This commit is contained in:
lik 2020-04-28 17:21:07 +08:00
parent eee4614161
commit 3306db1ff8
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,7 @@
'use strict'; 'use strict';
const Moment = require('moment');
function ctxresp(ctx, data, errno, errmsg) { function ctxresp(ctx, data, errno, errmsg) {
if (errno === null || errno === undefined) errno = 0; if (errno === null || errno === undefined) errno = 0;
if (errmsg === null || errmsg === undefined) errmsg = ''; if (errmsg === null || errmsg === undefined) errmsg = '';
@ -8,7 +10,8 @@ function ctxresp(ctx, data, errno, errmsg) {
ctx.body = { ctx.body = {
result: errno === 0 ? 'ok' : 'fail', result: errno === 0 ? 'ok' : 'fail',
error: { code: errno, msg: errmsg }, error: { code: errno, msg: errmsg },
data: data data: data,
stime: Moment().format('YYYY-MM-DD HH:mm:ss')
}; };
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@ehason/utils", "name": "@ehason/utils",
"version": "1.1.0", "version": "1.1.2",
"description": "Utils for ehason develope", "description": "Utils for ehason develope",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -9,6 +9,7 @@
"author": "likeagle <likeagle@163.com>", "author": "likeagle <likeagle@163.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"amqplib": "^0.5.5" "amqplib": "^0.5.5",
"moment": "^2.24.0"
} }
} }