abler-api 0.1.35 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/pp-util.js +31 -8
- package/dist/es/pp-util.js +10 -5
- package/package.json +2 -2
package/dist/cjs/pp-util.js
CHANGED
|
@@ -689,7 +689,7 @@ class apiUtil$2 {
|
|
|
689
689
|
static createApiCallRec(tokenData, req) {
|
|
690
690
|
if (!req.apiCallRec) {
|
|
691
691
|
if (req.apiCallRecId) {
|
|
692
|
-
return dbQueryOne(dbSql.loadApiUsage, {
|
|
692
|
+
return dbUtil.dbQueryOne(dbSql.loadApiUsage, {
|
|
693
693
|
replacements: {
|
|
694
694
|
id: req.apiCallRecId
|
|
695
695
|
}
|
|
@@ -698,10 +698,10 @@ class apiUtil$2 {
|
|
|
698
698
|
return req.apiCallRec;
|
|
699
699
|
});
|
|
700
700
|
} else {
|
|
701
|
-
let params = extractParams(req); // let contentLength = parseInt(req.headers["content-length"]) || 0;
|
|
701
|
+
let params = apiUtil$2.extractParams(req); // let contentLength = parseInt(req.headers["content-length"]) || 0;
|
|
702
702
|
|
|
703
703
|
let rec = {
|
|
704
|
-
id: newGuid(),
|
|
704
|
+
id: ppUtil$4.newGuid(),
|
|
705
705
|
companyId: tokenData.apiKey || '',
|
|
706
706
|
orderId: params.orderId || '',
|
|
707
707
|
signerId: params.signerId || '',
|
|
@@ -736,6 +736,24 @@ class apiUtil$2 {
|
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
return req.apiCallRec;
|
|
739
|
+
|
|
740
|
+
function _getBodyLogStr(req) {
|
|
741
|
+
let contentLength = parseInt(req.headers["content-length"]) || 0;
|
|
742
|
+
if (contentLength < 500) return req.rawBody || '';
|
|
743
|
+
let tempBody = {};
|
|
744
|
+
|
|
745
|
+
for (let key in req.body) {
|
|
746
|
+
let value = req.body[key];
|
|
747
|
+
|
|
748
|
+
if (typeof value == 'string' && value.length > 500) {
|
|
749
|
+
value = value.substring(0, 31) + '...(' + value.length + ')';
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
tempBody[key] = value;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return JSON.stringify(tempBody);
|
|
756
|
+
}
|
|
739
757
|
}
|
|
740
758
|
/**
|
|
741
759
|
* 查询机构信息
|
|
@@ -1077,9 +1095,14 @@ class apiUtil$2 {
|
|
|
1077
1095
|
|
|
1078
1096
|
static async hostIsMySelf(host, req) {
|
|
1079
1097
|
let clientIp = apiUtil$2.getClientIp(req);
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1098
|
+
|
|
1099
|
+
try {
|
|
1100
|
+
return !!ppUtil$4.getMyIp({
|
|
1101
|
+
hosts: [host, clientIp]
|
|
1102
|
+
});
|
|
1103
|
+
} catch (e) {
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1083
1106
|
}
|
|
1084
1107
|
/**
|
|
1085
1108
|
* 检查是否应该把请求转发到其它服务器,若是则转发
|
|
@@ -1462,7 +1485,7 @@ var ppUtilApi = apiUtil$2;
|
|
|
1462
1485
|
const fs = require$$4__default["default"];
|
|
1463
1486
|
const path = require$$1__default$1["default"];
|
|
1464
1487
|
const ppUtil$3 = require$$1__default["default"].ppUtil;
|
|
1465
|
-
const
|
|
1488
|
+
const ppRedis = require$$2__default["default"].ppRedis;
|
|
1466
1489
|
let conf$2, err$1; // const dbCheck = require('../dbupdate/dd-version');
|
|
1467
1490
|
|
|
1468
1491
|
/**
|
|
@@ -1614,7 +1637,7 @@ async function checkExEnvSetting(loadjs) {
|
|
|
1614
1637
|
|
|
1615
1638
|
async function checkRedis() {
|
|
1616
1639
|
if (!conf$2.redis.enabled) return "";
|
|
1617
|
-
const redis =
|
|
1640
|
+
const redis = ppRedis.newClient("kv"); // console.log(`checkRedis begin:`);
|
|
1618
1641
|
|
|
1619
1642
|
await ppUtil$3.wait(15 * 1000, param => {
|
|
1620
1643
|
if (redis.ready && redis.connected || redis.error) {
|
package/dist/es/pp-util.js
CHANGED
|
@@ -1064,9 +1064,14 @@ class apiUtil$2 {
|
|
|
1064
1064
|
|
|
1065
1065
|
static async hostIsMySelf(host, req) {
|
|
1066
1066
|
let clientIp = apiUtil$2.getClientIp(req);
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1067
|
+
|
|
1068
|
+
try {
|
|
1069
|
+
return !!ppUtil$4.getMyIp({
|
|
1070
|
+
hosts: [host, clientIp]
|
|
1071
|
+
});
|
|
1072
|
+
} catch (e) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1070
1075
|
}
|
|
1071
1076
|
/**
|
|
1072
1077
|
* 检查是否应该把请求转发到其它服务器,若是则转发
|
|
@@ -1449,7 +1454,7 @@ var ppUtilApi = apiUtil$2;
|
|
|
1449
1454
|
const fs = require$$4;
|
|
1450
1455
|
const path = require$$1$1;
|
|
1451
1456
|
const ppUtil$3 = require$$1.ppUtil;
|
|
1452
|
-
const
|
|
1457
|
+
const ppRedis = require$$2.ppRedis;
|
|
1453
1458
|
let conf$2, err$1; // const dbCheck = require('../dbupdate/dd-version');
|
|
1454
1459
|
|
|
1455
1460
|
/**
|
|
@@ -1601,7 +1606,7 @@ async function checkExEnvSetting(loadjs) {
|
|
|
1601
1606
|
|
|
1602
1607
|
async function checkRedis() {
|
|
1603
1608
|
if (!conf$2.redis.enabled) return "";
|
|
1604
|
-
const redis =
|
|
1609
|
+
const redis = ppRedis.newClient("kv"); // console.log(`checkRedis begin:`);
|
|
1605
1610
|
|
|
1606
1611
|
await ppUtil$3.wait(15 * 1000, param => {
|
|
1607
1612
|
if (redis.ready && redis.connected || redis.error) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abler-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "API服务相关工具",
|
|
5
5
|
"main": "./dist/cjs/pp-util.js",
|
|
6
|
-
"module": "./dist/es/pp-util.js",
|
|
6
|
+
"-module": "./dist/es/pp-util.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "npx rollup -c rollup.config.js",
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|