abler-api 0.1.70 → 0.1.72
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 +18 -18
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -33,7 +33,7 @@ const {
|
|
|
33
33
|
netUtil: netUtil$1
|
|
34
34
|
} = require$$4__default["default"];
|
|
35
35
|
const fs$1 = require$$5__default["default"];
|
|
36
|
-
let conf$3, appSetting
|
|
36
|
+
let conf$3, appSetting, err$2, dbSql;
|
|
37
37
|
const pnToken = "access_token",
|
|
38
38
|
hnToken = pnToken,
|
|
39
39
|
pnApiKey = "apiKey",
|
|
@@ -58,13 +58,13 @@ class apiUtil$2 {
|
|
|
58
58
|
|
|
59
59
|
static config(appConfig, appErrCfg, appDbSql) {
|
|
60
60
|
conf$3 = appConfig;
|
|
61
|
-
appSetting
|
|
61
|
+
appSetting = conf$3?.appSetting;
|
|
62
62
|
err$2 = appErrCfg;
|
|
63
63
|
dbSql = appDbSql;
|
|
64
64
|
ppUtil$4.config(appConfig, appErrCfg);
|
|
65
65
|
kvStorage$1.config(appConfig, appErrCfg);
|
|
66
|
-
apiUtil$2.debugFlag = appSetting
|
|
67
|
-
apiUtil$2.testFlag = appSetting
|
|
66
|
+
apiUtil$2.debugFlag = appSetting?.debugFlag || apiUtil$2.debugFlag;
|
|
67
|
+
apiUtil$2.testFlag = appSetting?.testFlag || apiUtil$2.testFlag; // apiUtil.apiCallRecSaver = apiCallRecSaver;
|
|
68
68
|
} //#region ===== 需要应用系统重写的方法
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -611,7 +611,7 @@ class apiUtil$2 {
|
|
|
611
611
|
|
|
612
612
|
|
|
613
613
|
static tokenExpireTime(req) {
|
|
614
|
-
return apiUtil$2.isDebugMode(req) ? 30 * 24 * 60 * 60 : apiUtil$2.isTestMode(req) ? 4 * 60 * 60 : appSetting
|
|
614
|
+
return apiUtil$2.isDebugMode(req) ? 30 * 24 * 60 * 60 : apiUtil$2.isTestMode(req) ? 4 * 60 * 60 : appSetting.tokenExpireTime;
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* 获取用户令牌保存键
|
|
@@ -1109,8 +1109,8 @@ class apiUtil$2 {
|
|
|
1109
1109
|
static getEnvHosts(params) {
|
|
1110
1110
|
configNeeded();
|
|
1111
1111
|
return {
|
|
1112
|
-
hosts: appSetting
|
|
1113
|
-
port: appSetting
|
|
1112
|
+
hosts: appSetting.serverHosts || ["localhost"],
|
|
1113
|
+
port: appSetting.listenPort || +params.port || 8443
|
|
1114
1114
|
};
|
|
1115
1115
|
}
|
|
1116
1116
|
/**
|
|
@@ -1574,7 +1574,7 @@ function configNeeded() {
|
|
|
1574
1574
|
if (!conf$3 || !err$2) {
|
|
1575
1575
|
ppUtil$4.configNeeded();
|
|
1576
1576
|
conf$3 = ppUtil$4.appConfig;
|
|
1577
|
-
appSetting
|
|
1577
|
+
appSetting = conf$3.appSetting;
|
|
1578
1578
|
err$2 = ppUtil$4.appErrCfg;
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
@@ -1854,8 +1854,8 @@ class commonMessenger$2 {
|
|
|
1854
1854
|
|
|
1855
1855
|
static initMessenger(appConfig, appErrCfg, msgChannel) {
|
|
1856
1856
|
conf$1 = appConfig;
|
|
1857
|
-
|
|
1858
|
-
|
|
1857
|
+
commonMessenger$2.redisMessenger = conf$1.redis.enabled ? new RedisMessenger(appConfig, appErrCfg, msgChannel).subscribe(msgChannel) : null;
|
|
1858
|
+
commonMessenger$2.myMsgAddr = commonMessenger$2.getMyMsgAddr();
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
1861
|
static getMyMsgAddr() {
|
|
@@ -1863,7 +1863,7 @@ class commonMessenger$2 {
|
|
|
1863
1863
|
conf$1.pm_id = process.env.pm_id || "0";
|
|
1864
1864
|
let myIp = ppUtil$2.getMyIp();
|
|
1865
1865
|
|
|
1866
|
-
if (
|
|
1866
|
+
if (commonMessenger$2.redisMessenger) {
|
|
1867
1867
|
myIp = `${conf$1.pm_id}@${myIp}`;
|
|
1868
1868
|
}
|
|
1869
1869
|
|
|
@@ -1874,9 +1874,9 @@ class commonMessenger$2 {
|
|
|
1874
1874
|
return conf$1.myMsgAddr;
|
|
1875
1875
|
}
|
|
1876
1876
|
|
|
1877
|
-
static setMessageHandle(messageHandle) {
|
|
1878
|
-
if (
|
|
1879
|
-
return
|
|
1877
|
+
static setMessageHandle(messageHandle, msgChannel) {
|
|
1878
|
+
if (commonMessenger$2.redisMessenger) {
|
|
1879
|
+
return commonMessenger$2.redisMessenger.setMessageHandle(messageHandle, msgChannel);
|
|
1880
1880
|
}
|
|
1881
1881
|
|
|
1882
1882
|
if (commonMessenger$2.onMessage.indexOf(messageHandle) < 0) {
|
|
@@ -1886,9 +1886,9 @@ class commonMessenger$2 {
|
|
|
1886
1886
|
return commonMessenger$2;
|
|
1887
1887
|
}
|
|
1888
1888
|
|
|
1889
|
-
static async publishMessage(message) {
|
|
1890
|
-
if (
|
|
1891
|
-
return
|
|
1889
|
+
static async publishMessage(message, msgChannel) {
|
|
1890
|
+
if (commonMessenger$2.redisMessenger) {
|
|
1891
|
+
return commonMessenger$2.redisMessenger.publish(message, msgChannel);
|
|
1892
1892
|
} else {
|
|
1893
1893
|
//没有消息处理器,则将消息转发到目标地址(不支持pm2多进程)
|
|
1894
1894
|
if (message.destAddr) {
|
|
@@ -1923,7 +1923,7 @@ class commonMessenger$2 {
|
|
|
1923
1923
|
|
|
1924
1924
|
async function forwardMessage(message) {
|
|
1925
1925
|
let reqOptions = {
|
|
1926
|
-
url: `https://${message.destAddr}:${appSetting.listenPort}/api/message`,
|
|
1926
|
+
url: `https://${message.destAddr}:${conf$1.appSetting.listenPort}/api/message`,
|
|
1927
1927
|
method: "POST",
|
|
1928
1928
|
data: message
|
|
1929
1929
|
};
|