@maiyunnet/kebab 9.16.0 → 9.16.2
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/doc/kebab-rag.md +106 -94
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/db/conn.js +13 -3
- package/lib/db/pool.js +21 -11
- package/lib/undici.d.ts +6 -3
- package/lib/undici.js +55 -47
- package/package.json +1 -1
- package/sys/route.js +1 -1
package/doc/kebab-rag.md
CHANGED
|
@@ -1361,7 +1361,7 @@ index/variables/VER.md
|
|
|
1361
1361
|
|
|
1362
1362
|
# Variable: VER
|
|
1363
1363
|
|
|
1364
|
-
> `const` **VER**: `"9.16.
|
|
1364
|
+
> `const` **VER**: `"9.16.2"` = `'9.16.2'`
|
|
1365
1365
|
|
|
1366
1366
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1367
1367
|
|
|
@@ -6958,7 +6958,7 @@ lib/db/conn/classes/Connection.md
|
|
|
6958
6958
|
|
|
6959
6959
|
# Class: Connection
|
|
6960
6960
|
|
|
6961
|
-
Defined in: [lib/db/conn.ts:
|
|
6961
|
+
Defined in: [lib/db/conn.ts:39](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L39)
|
|
6962
6962
|
|
|
6963
6963
|
数据库连接对象
|
|
6964
6964
|
|
|
@@ -6968,7 +6968,7 @@ Defined in: [lib/db/conn.ts:38](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
6968
6968
|
|
|
6969
6969
|
> **new Connection**(`etc`, `link`): `Connection`
|
|
6970
6970
|
|
|
6971
|
-
Defined in: [lib/db/conn.ts:
|
|
6971
|
+
Defined in: [lib/db/conn.ts:64](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L64)
|
|
6972
6972
|
|
|
6973
6973
|
#### Parameters
|
|
6974
6974
|
|
|
@@ -6990,7 +6990,7 @@ Defined in: [lib/db/conn.ts:63](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
6990
6990
|
|
|
6991
6991
|
> **beginTransaction**(): `Promise`\<`boolean`\>
|
|
6992
6992
|
|
|
6993
|
-
Defined in: [lib/db/conn.ts:
|
|
6993
|
+
Defined in: [lib/db/conn.ts:326](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L326)
|
|
6994
6994
|
|
|
6995
6995
|
#### Returns
|
|
6996
6996
|
|
|
@@ -7002,7 +7002,7 @@ Defined in: [lib/db/conn.ts:325](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7002
7002
|
|
|
7003
7003
|
> **commit**(): `Promise`\<`boolean`\>
|
|
7004
7004
|
|
|
7005
|
-
Defined in: [lib/db/conn.ts:
|
|
7005
|
+
Defined in: [lib/db/conn.ts:352](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L352)
|
|
7006
7006
|
|
|
7007
7007
|
#### Returns
|
|
7008
7008
|
|
|
@@ -7014,7 +7014,7 @@ Defined in: [lib/db/conn.ts:346](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7014
7014
|
|
|
7015
7015
|
> **end**(): `Promise`\<`boolean`\>
|
|
7016
7016
|
|
|
7017
|
-
Defined in: [lib/db/conn.ts:
|
|
7017
|
+
Defined in: [lib/db/conn.ts:315](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L315)
|
|
7018
7018
|
|
|
7019
7019
|
关闭连接,一般情况下不使用
|
|
7020
7020
|
|
|
@@ -7028,7 +7028,7 @@ Defined in: [lib/db/conn.ts:314](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7028
7028
|
|
|
7029
7029
|
> **execute**(`sql`, `values?`): `Promise`\<[`IPacket`](../../interfaces/IPacket.md)\>
|
|
7030
7030
|
|
|
7031
|
-
Defined in: [lib/db/conn.ts:
|
|
7031
|
+
Defined in: [lib/db/conn.ts:241](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L241)
|
|
7032
7032
|
|
|
7033
7033
|
执行一条 SQL 并获得影响行数对象 packet
|
|
7034
7034
|
|
|
@@ -7056,7 +7056,7 @@ Defined in: [lib/db/conn.ts:240](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7056
7056
|
|
|
7057
7057
|
> **getEtc**(): [`IConfigDb`](../../../../index/interfaces/IConfigDb.md)
|
|
7058
7058
|
|
|
7059
|
-
Defined in: [lib/db/conn.ts:
|
|
7059
|
+
Defined in: [lib/db/conn.ts:73](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L73)
|
|
7060
7060
|
|
|
7061
7061
|
获取连接 etc 信息
|
|
7062
7062
|
|
|
@@ -7070,7 +7070,7 @@ Defined in: [lib/db/conn.ts:72](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7070
7070
|
|
|
7071
7071
|
> **getLast**(): `number`
|
|
7072
7072
|
|
|
7073
|
-
Defined in: [lib/db/conn.ts:
|
|
7073
|
+
Defined in: [lib/db/conn.ts:85](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L85)
|
|
7074
7074
|
|
|
7075
7075
|
获取最后一次获取连接的时间
|
|
7076
7076
|
|
|
@@ -7084,7 +7084,7 @@ Defined in: [lib/db/conn.ts:84](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7084
7084
|
|
|
7085
7085
|
> **getLastSql**(): `object`[]
|
|
7086
7086
|
|
|
7087
|
-
Defined in: [lib/db/conn.ts:
|
|
7087
|
+
Defined in: [lib/db/conn.ts:92](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L92)
|
|
7088
7088
|
|
|
7089
7089
|
获取最后两次执行的 sql 字符串
|
|
7090
7090
|
|
|
@@ -7098,7 +7098,7 @@ Defined in: [lib/db/conn.ts:91](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7098
7098
|
|
|
7099
7099
|
> **getService**(): [`ESERVICE`](../../enumerations/ESERVICE.md)
|
|
7100
7100
|
|
|
7101
|
-
Defined in: [lib/db/conn.ts:
|
|
7101
|
+
Defined in: [lib/db/conn.ts:78](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L78)
|
|
7102
7102
|
|
|
7103
7103
|
获取数据库服务类型
|
|
7104
7104
|
|
|
@@ -7112,7 +7112,7 @@ Defined in: [lib/db/conn.ts:77](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7112
7112
|
|
|
7113
7113
|
> **isAvailable**(`last?`): `Promise`\<`boolean`\>
|
|
7114
7114
|
|
|
7115
|
-
Defined in: [lib/db/conn.ts:
|
|
7115
|
+
Defined in: [lib/db/conn.ts:159](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L159)
|
|
7116
7116
|
|
|
7117
7117
|
通过执行一条语句判断当前连接是否可用
|
|
7118
7118
|
|
|
@@ -7134,7 +7134,7 @@ Defined in: [lib/db/conn.ts:158](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7134
7134
|
|
|
7135
7135
|
> **isLost**(): `boolean`
|
|
7136
7136
|
|
|
7137
|
-
Defined in: [lib/db/conn.ts:
|
|
7137
|
+
Defined in: [lib/db/conn.ts:109](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L109)
|
|
7138
7138
|
|
|
7139
7139
|
是否已经丢失
|
|
7140
7140
|
|
|
@@ -7148,7 +7148,7 @@ Defined in: [lib/db/conn.ts:108](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7148
7148
|
|
|
7149
7149
|
> **isTransaction**(): `boolean`
|
|
7150
7150
|
|
|
7151
|
-
Defined in: [lib/db/conn.ts:
|
|
7151
|
+
Defined in: [lib/db/conn.ts:116](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L116)
|
|
7152
7152
|
|
|
7153
7153
|
是否是开启事务状态
|
|
7154
7154
|
|
|
@@ -7162,7 +7162,7 @@ Defined in: [lib/db/conn.ts:115](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7162
7162
|
|
|
7163
7163
|
> **isUsing**(): `boolean`
|
|
7164
7164
|
|
|
7165
|
-
Defined in: [lib/db/conn.ts:
|
|
7165
|
+
Defined in: [lib/db/conn.ts:123](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L123)
|
|
7166
7166
|
|
|
7167
7167
|
获取当前状态是否正在被使用中
|
|
7168
7168
|
|
|
@@ -7176,7 +7176,7 @@ Defined in: [lib/db/conn.ts:122](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7176
7176
|
|
|
7177
7177
|
> **query**(`sql`, `values?`): `Promise`\<[`IData`](../../interfaces/IData.md)\>
|
|
7178
7178
|
|
|
7179
|
-
Defined in: [lib/db/conn.ts:
|
|
7179
|
+
Defined in: [lib/db/conn.ts:182](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L182)
|
|
7180
7180
|
|
|
7181
7181
|
执行一条 SQL 并获得返回数据
|
|
7182
7182
|
|
|
@@ -7204,7 +7204,7 @@ Defined in: [lib/db/conn.ts:181](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7204
7204
|
|
|
7205
7205
|
> **refreshLast**(): `void`
|
|
7206
7206
|
|
|
7207
|
-
Defined in: [lib/db/conn.ts:
|
|
7207
|
+
Defined in: [lib/db/conn.ts:151](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L151)
|
|
7208
7208
|
|
|
7209
7209
|
设定最后使用时间
|
|
7210
7210
|
|
|
@@ -7218,7 +7218,7 @@ Defined in: [lib/db/conn.ts:150](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7218
7218
|
|
|
7219
7219
|
> **rollback**(): `Promise`\<`boolean`\>
|
|
7220
7220
|
|
|
7221
|
-
Defined in: [lib/db/conn.ts:
|
|
7221
|
+
Defined in: [lib/db/conn.ts:372](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L372)
|
|
7222
7222
|
|
|
7223
7223
|
#### Returns
|
|
7224
7224
|
|
|
@@ -7230,7 +7230,7 @@ Defined in: [lib/db/conn.ts:364](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7230
7230
|
|
|
7231
7231
|
> **setLost**(): `void`
|
|
7232
7232
|
|
|
7233
|
-
Defined in: [lib/db/conn.ts:
|
|
7233
|
+
Defined in: [lib/db/conn.ts:102](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L102)
|
|
7234
7234
|
|
|
7235
7235
|
将本条连接设置为不可用
|
|
7236
7236
|
|
|
@@ -7244,7 +7244,7 @@ Defined in: [lib/db/conn.ts:101](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7244
7244
|
|
|
7245
7245
|
> **used**(): `void`
|
|
7246
7246
|
|
|
7247
|
-
Defined in: [lib/db/conn.ts:
|
|
7247
|
+
Defined in: [lib/db/conn.ts:144](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L144)
|
|
7248
7248
|
|
|
7249
7249
|
取消占用
|
|
7250
7250
|
|
|
@@ -7258,7 +7258,7 @@ Defined in: [lib/db/conn.ts:143](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7258
7258
|
|
|
7259
7259
|
> **using**(): `boolean`
|
|
7260
7260
|
|
|
7261
|
-
Defined in: [lib/db/conn.ts:
|
|
7261
|
+
Defined in: [lib/db/conn.ts:130](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L130)
|
|
7262
7262
|
|
|
7263
7263
|
判断是否可用(丢失的也算不可用),返回 true 代表获取成功并自动刷新最后时间
|
|
7264
7264
|
|
|
@@ -7568,7 +7568,7 @@ lib/db/pool/classes/Pool.md
|
|
|
7568
7568
|
|
|
7569
7569
|
# Class: Pool
|
|
7570
7570
|
|
|
7571
|
-
Defined in: [lib/db/pool.ts:
|
|
7571
|
+
Defined in: [lib/db/pool.ts:122](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L122)
|
|
7572
7572
|
|
|
7573
7573
|
数据库连接池对象
|
|
7574
7574
|
|
|
@@ -7578,7 +7578,7 @@ Defined in: [lib/db/pool.ts:116](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7578
7578
|
|
|
7579
7579
|
> **new Pool**(`etc`, `opt`): `Pool`
|
|
7580
7580
|
|
|
7581
|
-
Defined in: [lib/db/pool.ts:
|
|
7581
|
+
Defined in: [lib/db/pool.ts:133](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L133)
|
|
7582
7582
|
|
|
7583
7583
|
#### Parameters
|
|
7584
7584
|
|
|
@@ -7604,7 +7604,7 @@ Defined in: [lib/db/pool.ts:127](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7604
7604
|
|
|
7605
7605
|
> **beginTransaction**(`ctr`): `Promise`\<[`Transaction`](../../tran/classes/Transaction.md) \| `null`\>
|
|
7606
7606
|
|
|
7607
|
-
Defined in: [lib/db/pool.ts:
|
|
7607
|
+
Defined in: [lib/db/pool.ts:201](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L201)
|
|
7608
7608
|
|
|
7609
7609
|
开启事务,返回事务对象并锁定连接,别人任何人不可用,有 ctr 的话必传 this,独立执行时可传 null
|
|
7610
7610
|
|
|
@@ -7624,7 +7624,7 @@ Defined in: [lib/db/pool.ts:195](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7624
7624
|
|
|
7625
7625
|
> **execute**(`sql`, `values?`): `Promise`\<[`IPacket`](../../interfaces/IPacket.md)\>
|
|
7626
7626
|
|
|
7627
|
-
Defined in: [lib/db/pool.ts:
|
|
7627
|
+
Defined in: [lib/db/pool.ts:181](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L181)
|
|
7628
7628
|
|
|
7629
7629
|
执行一条 SQL 并获得影响行数对象 packet,连接失败抛出错误
|
|
7630
7630
|
|
|
@@ -7652,7 +7652,7 @@ Defined in: [lib/db/pool.ts:175](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7652
7652
|
|
|
7653
7653
|
> **getName**(): `string`
|
|
7654
7654
|
|
|
7655
|
-
Defined in: [lib/db/pool.ts:
|
|
7655
|
+
Defined in: [lib/db/pool.ts:147](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L147)
|
|
7656
7656
|
|
|
7657
7657
|
获取当前连接的数据库名称
|
|
7658
7658
|
|
|
@@ -7666,7 +7666,7 @@ Defined in: [lib/db/pool.ts:141](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7666
7666
|
|
|
7667
7667
|
> **getQueries**(): `number`
|
|
7668
7668
|
|
|
7669
|
-
Defined in: [lib/db/pool.ts:
|
|
7669
|
+
Defined in: [lib/db/pool.ts:339](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L339)
|
|
7670
7670
|
|
|
7671
7671
|
获取 SQL 执行次数
|
|
7672
7672
|
|
|
@@ -7680,7 +7680,7 @@ Defined in: [lib/db/pool.ts:327](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7680
7680
|
|
|
7681
7681
|
> **getService**(): [`ESERVICE`](../../enumerations/ESERVICE.md)
|
|
7682
7682
|
|
|
7683
|
-
Defined in: [lib/db/pool.ts:
|
|
7683
|
+
Defined in: [lib/db/pool.ts:142](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L142)
|
|
7684
7684
|
|
|
7685
7685
|
获取当前连接的服务商
|
|
7686
7686
|
|
|
@@ -7694,7 +7694,7 @@ Defined in: [lib/db/pool.ts:136](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7694
7694
|
|
|
7695
7695
|
> **query**(`sql`, `values?`): `Promise`\<[`IData`](../../interfaces/IData.md)\>
|
|
7696
7696
|
|
|
7697
|
-
Defined in: [lib/db/pool.ts:
|
|
7697
|
+
Defined in: [lib/db/pool.ts:157](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L157)
|
|
7698
7698
|
|
|
7699
7699
|
执行一条 SQL,无视顺序和相同连接,随用随取
|
|
7700
7700
|
|
|
@@ -7731,7 +7731,7 @@ lib/db/pool/functions/getConnectionList.md
|
|
|
7731
7731
|
|
|
7732
7732
|
> **getConnectionList**(): [`IConnectionInfo`](../interfaces/IConnectionInfo.md)[]
|
|
7733
7733
|
|
|
7734
|
-
Defined in: [lib/db/pool.ts:
|
|
7734
|
+
Defined in: [lib/db/pool.ts:41](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L41)
|
|
7735
7735
|
|
|
7736
7736
|
获取当前连接池中所有连接的信息
|
|
7737
7737
|
|
|
@@ -7773,7 +7773,7 @@ lib/db/pool/interfaces/IConnectionInfo.md
|
|
|
7773
7773
|
|
|
7774
7774
|
# Interface: IConnectionInfo
|
|
7775
7775
|
|
|
7776
|
-
Defined in: [lib/db/pool.ts:
|
|
7776
|
+
Defined in: [lib/db/pool.ts:24](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L24)
|
|
7777
7777
|
|
|
7778
7778
|
连接信息
|
|
7779
7779
|
|
|
@@ -7783,7 +7783,7 @@ Defined in: [lib/db/pool.ts:18](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7783
7783
|
|
|
7784
7784
|
> **host**: `string`
|
|
7785
7785
|
|
|
7786
|
-
Defined in: [lib/db/pool.ts:
|
|
7786
|
+
Defined in: [lib/db/pool.ts:28](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L28)
|
|
7787
7787
|
|
|
7788
7788
|
***
|
|
7789
7789
|
|
|
@@ -7791,7 +7791,7 @@ Defined in: [lib/db/pool.ts:22](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7791
7791
|
|
|
7792
7792
|
> **id**: `number`
|
|
7793
7793
|
|
|
7794
|
-
Defined in: [lib/db/pool.ts:
|
|
7794
|
+
Defined in: [lib/db/pool.ts:25](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L25)
|
|
7795
7795
|
|
|
7796
7796
|
***
|
|
7797
7797
|
|
|
@@ -7799,7 +7799,7 @@ Defined in: [lib/db/pool.ts:19](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7799
7799
|
|
|
7800
7800
|
> **last**: `number`
|
|
7801
7801
|
|
|
7802
|
-
Defined in: [lib/db/pool.ts:
|
|
7802
|
+
Defined in: [lib/db/pool.ts:27](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L27)
|
|
7803
7803
|
|
|
7804
7804
|
***
|
|
7805
7805
|
|
|
@@ -7807,7 +7807,7 @@ Defined in: [lib/db/pool.ts:21](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7807
7807
|
|
|
7808
7808
|
> **lost**: `boolean`
|
|
7809
7809
|
|
|
7810
|
-
Defined in: [lib/db/pool.ts:
|
|
7810
|
+
Defined in: [lib/db/pool.ts:33](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L33)
|
|
7811
7811
|
|
|
7812
7812
|
***
|
|
7813
7813
|
|
|
@@ -7815,7 +7815,7 @@ Defined in: [lib/db/pool.ts:27](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7815
7815
|
|
|
7816
7816
|
> `optional` **name?**: `string`
|
|
7817
7817
|
|
|
7818
|
-
Defined in: [lib/db/pool.ts:
|
|
7818
|
+
Defined in: [lib/db/pool.ts:30](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L30)
|
|
7819
7819
|
|
|
7820
7820
|
***
|
|
7821
7821
|
|
|
@@ -7823,7 +7823,7 @@ Defined in: [lib/db/pool.ts:24](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7823
7823
|
|
|
7824
7824
|
> **port**: `number`
|
|
7825
7825
|
|
|
7826
|
-
Defined in: [lib/db/pool.ts:
|
|
7826
|
+
Defined in: [lib/db/pool.ts:29](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L29)
|
|
7827
7827
|
|
|
7828
7828
|
***
|
|
7829
7829
|
|
|
@@ -7831,7 +7831,7 @@ Defined in: [lib/db/pool.ts:23](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7831
7831
|
|
|
7832
7832
|
> **service**: [`ESERVICE`](../../enumerations/ESERVICE.md)
|
|
7833
7833
|
|
|
7834
|
-
Defined in: [lib/db/pool.ts:
|
|
7834
|
+
Defined in: [lib/db/pool.ts:26](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L26)
|
|
7835
7835
|
|
|
7836
7836
|
***
|
|
7837
7837
|
|
|
@@ -7839,7 +7839,7 @@ Defined in: [lib/db/pool.ts:20](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7839
7839
|
|
|
7840
7840
|
> **transaction**: `boolean`
|
|
7841
7841
|
|
|
7842
|
-
Defined in: [lib/db/pool.ts:
|
|
7842
|
+
Defined in: [lib/db/pool.ts:35](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L35)
|
|
7843
7843
|
|
|
7844
7844
|
***
|
|
7845
7845
|
|
|
@@ -7847,7 +7847,7 @@ Defined in: [lib/db/pool.ts:29](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7847
7847
|
|
|
7848
7848
|
> **user**: `string`
|
|
7849
7849
|
|
|
7850
|
-
Defined in: [lib/db/pool.ts:
|
|
7850
|
+
Defined in: [lib/db/pool.ts:31](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L31)
|
|
7851
7851
|
|
|
7852
7852
|
***
|
|
7853
7853
|
|
|
@@ -7855,7 +7855,7 @@ Defined in: [lib/db/pool.ts:25](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
7855
7855
|
|
|
7856
7856
|
> **using**: `boolean`
|
|
7857
7857
|
|
|
7858
|
-
Defined in: [lib/db/pool.ts:
|
|
7858
|
+
Defined in: [lib/db/pool.ts:34](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L34)
|
|
7859
7859
|
|
|
7860
7860
|
lib/db/tran/classes/Transaction.md
|
|
7861
7861
|
---
|
|
@@ -18544,7 +18544,7 @@ lib/undici/functions/fetch.md
|
|
|
18544
18544
|
|
|
18545
18545
|
> **fetch**(`input`, `init?`): `Promise`\<`Response`\>
|
|
18546
18546
|
|
|
18547
|
-
Defined in: [lib/undici.ts:
|
|
18547
|
+
Defined in: [lib/undici.ts:260](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L260)
|
|
18548
18548
|
|
|
18549
18549
|
发起一个完全兼容 fetch 的请求
|
|
18550
18550
|
|
|
@@ -18579,7 +18579,7 @@ lib/undici/functions/filterHeaders.md
|
|
|
18579
18579
|
|
|
18580
18580
|
> **filterHeaders**(`headers`, `res?`, `filter?`): `Record`\<`string`, `string` \| `string`[]\>
|
|
18581
18581
|
|
|
18582
|
-
Defined in: [lib/undici.ts:
|
|
18582
|
+
Defined in: [lib/undici.ts:634](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L634)
|
|
18583
18583
|
|
|
18584
18584
|
剔除不代理的 header,返回新的 header
|
|
18585
18585
|
|
|
@@ -18620,7 +18620,7 @@ lib/undici/functions/getFormData.md
|
|
|
18620
18620
|
|
|
18621
18621
|
> **getFormData**(): [`FormData`](../formdata/classes/FormData.md)
|
|
18622
18622
|
|
|
18623
|
-
Defined in: [lib/undici.ts:
|
|
18623
|
+
Defined in: [lib/undici.ts:618](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L618)
|
|
18624
18624
|
|
|
18625
18625
|
创建 FormData 对象
|
|
18626
18626
|
|
|
@@ -18641,7 +18641,7 @@ lib/undici/functions/get.md
|
|
|
18641
18641
|
|
|
18642
18642
|
> **get**(`u`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
|
|
18643
18643
|
|
|
18644
|
-
Defined in: [lib/undici.ts:
|
|
18644
|
+
Defined in: [lib/undici.ts:138](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L138)
|
|
18645
18645
|
|
|
18646
18646
|
发起一个 get 请求
|
|
18647
18647
|
|
|
@@ -18703,7 +18703,7 @@ lib/undici/functions/getResponseJson.md
|
|
|
18703
18703
|
|
|
18704
18704
|
> **getResponseJson**(`u`, `opt?`): `Promise`\<`any`\>
|
|
18705
18705
|
|
|
18706
|
-
Defined in: [lib/undici.ts:
|
|
18706
|
+
Defined in: [lib/undici.ts:248](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L248)
|
|
18707
18707
|
|
|
18708
18708
|
发起 GET 请求并解析 JSON 响应
|
|
18709
18709
|
|
|
@@ -18725,7 +18725,7 @@ Defined in: [lib/undici.ts:218](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
18725
18725
|
|
|
18726
18726
|
`Promise`\<`any`\>
|
|
18727
18727
|
|
|
18728
|
-
JSON
|
|
18728
|
+
JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
18729
18729
|
|
|
18730
18730
|
lib/undici/functions/mproxyData.md
|
|
18731
18731
|
---
|
|
@@ -18740,7 +18740,7 @@ lib/undici/functions/mproxyData.md
|
|
|
18740
18740
|
|
|
18741
18741
|
> **mproxyData**(`ctr`): `any`
|
|
18742
18742
|
|
|
18743
|
-
Defined in: [lib/undici.ts:
|
|
18743
|
+
Defined in: [lib/undici.ts:736](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L736)
|
|
18744
18744
|
|
|
18745
18745
|
获取 mproxy 的附加数据
|
|
18746
18746
|
|
|
@@ -18769,7 +18769,7 @@ lib/undici/functions/mproxy.md
|
|
|
18769
18769
|
|
|
18770
18770
|
> **mproxy**(`ctr`, `auth`, `opt?`): `Promise`\<`number`\>
|
|
18771
18771
|
|
|
18772
|
-
Defined in: [lib/undici.ts:
|
|
18772
|
+
Defined in: [lib/undici.ts:674](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L674)
|
|
18773
18773
|
|
|
18774
18774
|
正向 mproxy 代理,注意提前处理不要自动处理 post 数据,读取 get 的 url 为实际请求地址
|
|
18775
18775
|
get: url, auth
|
|
@@ -18811,7 +18811,7 @@ lib/undici/functions/open.md
|
|
|
18811
18811
|
|
|
18812
18812
|
> **open**(`u`): [`Request`](../request/classes/Request.md)
|
|
18813
18813
|
|
|
18814
|
-
Defined in: [lib/undici.ts:
|
|
18814
|
+
Defined in: [lib/undici.ts:129](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L129)
|
|
18815
18815
|
|
|
18816
18816
|
创建一个请求对象
|
|
18817
18817
|
|
|
@@ -18838,7 +18838,7 @@ lib/undici/functions/postJson.md
|
|
|
18838
18838
|
|
|
18839
18839
|
> **postJson**(`u`, `data`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
|
|
18840
18840
|
|
|
18841
|
-
Defined in: [lib/undici.ts:
|
|
18841
|
+
Defined in: [lib/undici.ts:163](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L163)
|
|
18842
18842
|
|
|
18843
18843
|
发起 JSON 请求
|
|
18844
18844
|
|
|
@@ -18879,9 +18879,9 @@ lib/undici/functions/postJsonResponseJson.md
|
|
|
18879
18879
|
|
|
18880
18880
|
> **postJsonResponseJson**(`u`, `data`, `opt?`): `Promise`\<`any`\>
|
|
18881
18881
|
|
|
18882
|
-
Defined in: [lib/undici.ts:
|
|
18882
|
+
Defined in: [lib/undici.ts:220](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L220)
|
|
18883
18883
|
|
|
18884
|
-
发起 JSON 请求并解析 JSON
|
|
18884
|
+
发起 JSON 请求并解析 JSON 响应
|
|
18885
18885
|
|
|
18886
18886
|
## Parameters
|
|
18887
18887
|
|
|
@@ -18907,6 +18907,8 @@ Defined in: [lib/undici.ts:164](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
18907
18907
|
|
|
18908
18908
|
`Promise`\<`any`\>
|
|
18909
18909
|
|
|
18910
|
+
JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
18911
|
+
|
|
18910
18912
|
lib/undici/functions/post.md
|
|
18911
18913
|
---
|
|
18912
18914
|
|
|
@@ -18920,7 +18922,7 @@ lib/undici/functions/post.md
|
|
|
18920
18922
|
|
|
18921
18923
|
> **post**(`u`, `data`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
|
|
18922
18924
|
|
|
18923
|
-
Defined in: [lib/undici.ts:
|
|
18925
|
+
Defined in: [lib/undici.ts:148](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L148)
|
|
18924
18926
|
|
|
18925
18927
|
发起一个 post 请求
|
|
18926
18928
|
|
|
@@ -18961,7 +18963,7 @@ lib/undici/functions/postResponseJson.md
|
|
|
18961
18963
|
|
|
18962
18964
|
> **postResponseJson**(`u`, `data`, `opt?`): `Promise`\<`any`\>
|
|
18963
18965
|
|
|
18964
|
-
Defined in: [lib/undici.ts:
|
|
18966
|
+
Defined in: [lib/undici.ts:235](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L235)
|
|
18965
18967
|
|
|
18966
18968
|
发起 POST 请求并解析 JSON 响应
|
|
18967
18969
|
|
|
@@ -18989,7 +18991,7 @@ Defined in: [lib/undici.ts:192](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
18989
18991
|
|
|
18990
18992
|
`Promise`\<`any`\>
|
|
18991
18993
|
|
|
18992
|
-
JSON
|
|
18994
|
+
JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
18993
18995
|
|
|
18994
18996
|
lib/undici/functions/request.md
|
|
18995
18997
|
---
|
|
@@ -19004,7 +19006,7 @@ lib/undici/functions/request.md
|
|
|
19004
19006
|
|
|
19005
19007
|
> **request**(`u`, `data?`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
|
|
19006
19008
|
|
|
19007
|
-
Defined in: [lib/undici.ts:
|
|
19009
|
+
Defined in: [lib/undici.ts:432](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L432)
|
|
19008
19010
|
|
|
19009
19011
|
发起一个请求
|
|
19010
19012
|
|
|
@@ -19041,7 +19043,7 @@ lib/undici/functions/rproxy.md
|
|
|
19041
19043
|
|
|
19042
19044
|
> **rproxy**(`ctr`, `route`, `opt?`): `Promise`\<`boolean`\>
|
|
19043
19045
|
|
|
19044
|
-
Defined in: [lib/undici.ts:
|
|
19046
|
+
Defined in: [lib/undici.ts:766](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L766)
|
|
19045
19047
|
|
|
19046
19048
|
反向代理,将本服务器的某个路由反代到其他网址
|
|
19047
19049
|
|
|
@@ -19130,7 +19132,7 @@ lib/undici/interfaces/IMproxyOptions.md
|
|
|
19130
19132
|
|
|
19131
19133
|
# Interface: IMproxyOptions
|
|
19132
19134
|
|
|
19133
|
-
Defined in: [lib/undici.ts:
|
|
19135
|
+
Defined in: [lib/undici.ts:889](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L889)
|
|
19134
19136
|
|
|
19135
19137
|
正向代理请求的传入参数选项
|
|
19136
19138
|
|
|
@@ -19140,7 +19142,7 @@ Defined in: [lib/undici.ts:870](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19140
19142
|
|
|
19141
19143
|
> `optional` **filter?**: (`h`) => `boolean`
|
|
19142
19144
|
|
|
19143
|
-
Defined in: [lib/undici.ts:
|
|
19145
|
+
Defined in: [lib/undici.ts:898](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L898)
|
|
19144
19146
|
|
|
19145
19147
|
过滤 header,返回 true 则留下
|
|
19146
19148
|
|
|
@@ -19160,7 +19162,7 @@ Defined in: [lib/undici.ts:879](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19160
19162
|
|
|
19161
19163
|
> `optional` **follow?**: `number`
|
|
19162
19164
|
|
|
19163
|
-
Defined in: [lib/undici.ts:
|
|
19165
|
+
Defined in: [lib/undici.ts:892](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L892)
|
|
19164
19166
|
|
|
19165
19167
|
***
|
|
19166
19168
|
|
|
@@ -19168,7 +19170,7 @@ Defined in: [lib/undici.ts:873](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19168
19170
|
|
|
19169
19171
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
19170
19172
|
|
|
19171
|
-
Defined in: [lib/undici.ts:
|
|
19173
|
+
Defined in: [lib/undici.ts:896](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L896)
|
|
19172
19174
|
|
|
19173
19175
|
***
|
|
19174
19176
|
|
|
@@ -19176,7 +19178,7 @@ Defined in: [lib/undici.ts:877](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19176
19178
|
|
|
19177
19179
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
19178
19180
|
|
|
19179
|
-
Defined in: [lib/undici.ts:
|
|
19181
|
+
Defined in: [lib/undici.ts:894](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L894)
|
|
19180
19182
|
|
|
19181
19183
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
19182
19184
|
|
|
@@ -19186,7 +19188,7 @@ Defined in: [lib/undici.ts:875](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19186
19188
|
|
|
19187
19189
|
> `optional` **local?**: `string`
|
|
19188
19190
|
|
|
19189
|
-
Defined in: [lib/undici.ts:
|
|
19191
|
+
Defined in: [lib/undici.ts:895](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L895)
|
|
19190
19192
|
|
|
19191
19193
|
***
|
|
19192
19194
|
|
|
@@ -19194,7 +19196,7 @@ Defined in: [lib/undici.ts:876](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19194
19196
|
|
|
19195
19197
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
19196
19198
|
|
|
19197
|
-
Defined in: [lib/undici.ts:
|
|
19199
|
+
Defined in: [lib/undici.ts:900](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L900)
|
|
19198
19200
|
|
|
19199
19201
|
默认为 default
|
|
19200
19202
|
|
|
@@ -19204,7 +19206,7 @@ Defined in: [lib/undici.ts:881](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19204
19206
|
|
|
19205
19207
|
> `optional` **timeout?**: `number`
|
|
19206
19208
|
|
|
19207
|
-
Defined in: [lib/undici.ts:
|
|
19209
|
+
Defined in: [lib/undici.ts:891](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L891)
|
|
19208
19210
|
|
|
19209
19211
|
秒数,默认 300 秒
|
|
19210
19212
|
|
|
@@ -19219,7 +19221,7 @@ lib/undici/interfaces/IRequestOptions.md
|
|
|
19219
19221
|
|
|
19220
19222
|
# Interface: IRequestOptions
|
|
19221
19223
|
|
|
19222
|
-
Defined in: [lib/undici.ts:
|
|
19224
|
+
Defined in: [lib/undici.ts:852](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L852)
|
|
19223
19225
|
|
|
19224
19226
|
请求的传入参数选项
|
|
19225
19227
|
|
|
@@ -19229,7 +19231,7 @@ Defined in: [lib/undici.ts:835](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19229
19231
|
|
|
19230
19232
|
> `optional` **cookie?**: `Record`\<`string`, [`ICookie`](../../cookie/interfaces/ICookie.md)\>
|
|
19231
19233
|
|
|
19232
|
-
Defined in: [lib/undici.ts:
|
|
19234
|
+
Defined in: [lib/undici.ts:881](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L881)
|
|
19233
19235
|
|
|
19234
19236
|
cookie 托管对象
|
|
19235
19237
|
|
|
@@ -19239,7 +19241,7 @@ cookie 托管对象
|
|
|
19239
19241
|
|
|
19240
19242
|
> `optional` **follow?**: `number`
|
|
19241
19243
|
|
|
19242
|
-
Defined in: [lib/undici.ts:
|
|
19244
|
+
Defined in: [lib/undici.ts:862](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L862)
|
|
19243
19245
|
|
|
19244
19246
|
追踪 location 次数,0 为不追踪,默认为 0
|
|
19245
19247
|
|
|
@@ -19249,7 +19251,7 @@ Defined in: [lib/undici.ts:843](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19249
19251
|
|
|
19250
19252
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
19251
19253
|
|
|
19252
|
-
Defined in: [lib/undici.ts:
|
|
19254
|
+
Defined in: [lib/undici.ts:867](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L867)
|
|
19253
19255
|
|
|
19254
19256
|
***
|
|
19255
19257
|
|
|
@@ -19257,7 +19259,7 @@ Defined in: [lib/undici.ts:848](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19257
19259
|
|
|
19258
19260
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
19259
19261
|
|
|
19260
|
-
Defined in: [lib/undici.ts:
|
|
19262
|
+
Defined in: [lib/undici.ts:864](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L864)
|
|
19261
19263
|
|
|
19262
19264
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
19263
19265
|
|
|
@@ -19267,7 +19269,7 @@ Defined in: [lib/undici.ts:845](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19267
19269
|
|
|
19268
19270
|
> `optional` **keep?**: `boolean`
|
|
19269
19271
|
|
|
19270
|
-
Defined in: [lib/undici.ts:
|
|
19272
|
+
Defined in: [lib/undici.ts:877](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L877)
|
|
19271
19273
|
|
|
19272
19274
|
连接是否保持长连接(即是否允许复用),默认为 true
|
|
19273
19275
|
|
|
@@ -19277,7 +19279,7 @@ Defined in: [lib/undici.ts:858](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19277
19279
|
|
|
19278
19280
|
> `optional` **local?**: `string`
|
|
19279
19281
|
|
|
19280
|
-
Defined in: [lib/undici.ts:
|
|
19282
|
+
Defined in: [lib/undici.ts:866](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L866)
|
|
19281
19283
|
|
|
19282
19284
|
***
|
|
19283
19285
|
|
|
@@ -19285,7 +19287,7 @@ Defined in: [lib/undici.ts:847](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19285
19287
|
|
|
19286
19288
|
> `optional` **log?**: `boolean`
|
|
19287
19289
|
|
|
19288
|
-
Defined in: [lib/undici.ts:
|
|
19290
|
+
Defined in: [lib/undici.ts:883](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L883)
|
|
19289
19291
|
|
|
19290
19292
|
若有异常写入文件日志,默认为 true
|
|
19291
19293
|
|
|
@@ -19295,7 +19297,7 @@ Defined in: [lib/undici.ts:864](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19295
19297
|
|
|
19296
19298
|
> `optional` **method?**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"OPTIONS"`
|
|
19297
19299
|
|
|
19298
|
-
Defined in: [lib/undici.ts:
|
|
19300
|
+
Defined in: [lib/undici.ts:853](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L853)
|
|
19299
19301
|
|
|
19300
19302
|
***
|
|
19301
19303
|
|
|
@@ -19303,7 +19305,7 @@ Defined in: [lib/undici.ts:836](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19303
19305
|
|
|
19304
19306
|
> `optional` **mproxy?**: `object`
|
|
19305
19307
|
|
|
19306
|
-
Defined in: [lib/undici.ts:
|
|
19308
|
+
Defined in: [lib/undici.ts:869](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L869)
|
|
19307
19309
|
|
|
19308
19310
|
正向 mproxy 代理,url 如 https://xxx/abc
|
|
19309
19311
|
|
|
@@ -19331,17 +19333,27 @@ Defined in: [lib/undici.ts:850](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19331
19333
|
|
|
19332
19334
|
> `optional` **retry?**: `number`
|
|
19333
19335
|
|
|
19334
|
-
Defined in: [lib/undici.ts:
|
|
19336
|
+
Defined in: [lib/undici.ts:858](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L858)
|
|
19335
19337
|
|
|
19336
19338
|
网络异常后的重试次数,默认 0;流式请求体不可重试,非幂等请求需由调用方保证安全
|
|
19337
19339
|
|
|
19338
19340
|
***
|
|
19339
19341
|
|
|
19342
|
+
### retryJson?
|
|
19343
|
+
|
|
19344
|
+
> `optional` **retryJson?**: `number`
|
|
19345
|
+
|
|
19346
|
+
Defined in: [lib/undici.ts:860](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L860)
|
|
19347
|
+
|
|
19348
|
+
JSON 解析失败后的重试次数,默认 0;仅适用于 ResponseJson 快捷方法,非幂等请求需由调用方保证安全
|
|
19349
|
+
|
|
19350
|
+
***
|
|
19351
|
+
|
|
19340
19352
|
### reuse?
|
|
19341
19353
|
|
|
19342
19354
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
19343
19355
|
|
|
19344
|
-
Defined in: [lib/undici.ts:
|
|
19356
|
+
Defined in: [lib/undici.ts:879](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L879)
|
|
19345
19357
|
|
|
19346
19358
|
复用池名/Agent,默认为 default
|
|
19347
19359
|
|
|
@@ -19351,7 +19363,7 @@ Defined in: [lib/undici.ts:860](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19351
19363
|
|
|
19352
19364
|
> `optional` **save?**: `string`
|
|
19353
19365
|
|
|
19354
|
-
Defined in: [lib/undici.ts:
|
|
19366
|
+
Defined in: [lib/undici.ts:865](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L865)
|
|
19355
19367
|
|
|
19356
19368
|
***
|
|
19357
19369
|
|
|
@@ -19359,7 +19371,7 @@ Defined in: [lib/undici.ts:846](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19359
19371
|
|
|
19360
19372
|
> `optional` **signal?**: `AbortSignal`
|
|
19361
19373
|
|
|
19362
|
-
Defined in: [lib/undici.ts:
|
|
19374
|
+
Defined in: [lib/undici.ts:885](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L885)
|
|
19363
19375
|
|
|
19364
19376
|
请求中止信号
|
|
19365
19377
|
|
|
@@ -19369,7 +19381,7 @@ Defined in: [lib/undici.ts:866](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19369
19381
|
|
|
19370
19382
|
> `optional` **timeout?**: `number`
|
|
19371
19383
|
|
|
19372
|
-
Defined in: [lib/undici.ts:
|
|
19384
|
+
Defined in: [lib/undici.ts:856](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L856)
|
|
19373
19385
|
|
|
19374
19386
|
秒数,默认 300 秒
|
|
19375
19387
|
|
|
@@ -19379,7 +19391,7 @@ Defined in: [lib/undici.ts:839](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19379
19391
|
|
|
19380
19392
|
> `optional` **type?**: `"form"` \| `"json"`
|
|
19381
19393
|
|
|
19382
|
-
Defined in: [lib/undici.ts:
|
|
19394
|
+
Defined in: [lib/undici.ts:854](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L854)
|
|
19383
19395
|
|
|
19384
19396
|
lib/undici/interfaces/IRproxyOptions.md
|
|
19385
19397
|
---
|
|
@@ -19392,7 +19404,7 @@ lib/undici/interfaces/IRproxyOptions.md
|
|
|
19392
19404
|
|
|
19393
19405
|
# Interface: IRproxyOptions
|
|
19394
19406
|
|
|
19395
|
-
Defined in: [lib/undici.ts:
|
|
19407
|
+
Defined in: [lib/undici.ts:904](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L904)
|
|
19396
19408
|
|
|
19397
19409
|
反向代理请求的传入参数选项
|
|
19398
19410
|
|
|
@@ -19402,7 +19414,7 @@ Defined in: [lib/undici.ts:885](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19402
19414
|
|
|
19403
19415
|
> `optional` **body?**: `string` \| `Buffer`\<`ArrayBufferLike`\> \| `Readable`
|
|
19404
19416
|
|
|
19405
|
-
Defined in: [lib/undici.ts:
|
|
19417
|
+
Defined in: [lib/undici.ts:923](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L923)
|
|
19406
19418
|
|
|
19407
19419
|
手动传入请求体(优先于原始 req 流),用于 req 流已消费后仍需转发 body 的场景
|
|
19408
19420
|
|
|
@@ -19412,7 +19424,7 @@ Defined in: [lib/undici.ts:904](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19412
19424
|
|
|
19413
19425
|
> `optional` **filter?**: (`h`) => `boolean`
|
|
19414
19426
|
|
|
19415
|
-
Defined in: [lib/undici.ts:
|
|
19427
|
+
Defined in: [lib/undici.ts:913](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L913)
|
|
19416
19428
|
|
|
19417
19429
|
过滤 header,返回 true 则留下
|
|
19418
19430
|
|
|
@@ -19432,7 +19444,7 @@ Defined in: [lib/undici.ts:894](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19432
19444
|
|
|
19433
19445
|
> `optional` **follow?**: `number`
|
|
19434
19446
|
|
|
19435
|
-
Defined in: [lib/undici.ts:
|
|
19447
|
+
Defined in: [lib/undici.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L907)
|
|
19436
19448
|
|
|
19437
19449
|
***
|
|
19438
19450
|
|
|
@@ -19440,7 +19452,7 @@ Defined in: [lib/undici.ts:888](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19440
19452
|
|
|
19441
19453
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
19442
19454
|
|
|
19443
|
-
Defined in: [lib/undici.ts:
|
|
19455
|
+
Defined in: [lib/undici.ts:911](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L911)
|
|
19444
19456
|
|
|
19445
19457
|
***
|
|
19446
19458
|
|
|
@@ -19448,7 +19460,7 @@ Defined in: [lib/undici.ts:892](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19448
19460
|
|
|
19449
19461
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
19450
19462
|
|
|
19451
|
-
Defined in: [lib/undici.ts:
|
|
19463
|
+
Defined in: [lib/undici.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L909)
|
|
19452
19464
|
|
|
19453
19465
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
19454
19466
|
|
|
@@ -19458,7 +19470,7 @@ Defined in: [lib/undici.ts:890](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19458
19470
|
|
|
19459
19471
|
> `optional` **local?**: `string`
|
|
19460
19472
|
|
|
19461
|
-
Defined in: [lib/undici.ts:
|
|
19473
|
+
Defined in: [lib/undici.ts:910](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L910)
|
|
19462
19474
|
|
|
19463
19475
|
***
|
|
19464
19476
|
|
|
@@ -19466,7 +19478,7 @@ Defined in: [lib/undici.ts:891](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19466
19478
|
|
|
19467
19479
|
> `optional` **mproxy?**: `object`
|
|
19468
19480
|
|
|
19469
|
-
Defined in: [lib/undici.ts:
|
|
19481
|
+
Defined in: [lib/undici.ts:915](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L915)
|
|
19470
19482
|
|
|
19471
19483
|
正向 mproxy 代理,url 如 https://xxx/abc
|
|
19472
19484
|
|
|
@@ -19494,7 +19506,7 @@ Defined in: [lib/undici.ts:896](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19494
19506
|
|
|
19495
19507
|
> `optional` **querys?**: `Record`\<`string`, `any`\>
|
|
19496
19508
|
|
|
19497
|
-
Defined in: [lib/undici.ts:
|
|
19509
|
+
Defined in: [lib/undici.ts:925](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L925)
|
|
19498
19510
|
|
|
19499
19511
|
自定义 GET 查询参数,传入后直接替换代理目标 URL 的整个 query string
|
|
19500
19512
|
|
|
@@ -19504,7 +19516,7 @@ Defined in: [lib/undici.ts:906](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19504
19516
|
|
|
19505
19517
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
19506
19518
|
|
|
19507
|
-
Defined in: [lib/undici.ts:
|
|
19519
|
+
Defined in: [lib/undici.ts:927](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L927)
|
|
19508
19520
|
|
|
19509
19521
|
默认为 default
|
|
19510
19522
|
|
|
@@ -19514,7 +19526,7 @@ Defined in: [lib/undici.ts:908](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
19514
19526
|
|
|
19515
19527
|
> `optional` **timeout?**: `number`
|
|
19516
19528
|
|
|
19517
|
-
Defined in: [lib/undici.ts:
|
|
19529
|
+
Defined in: [lib/undici.ts:906](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L906)
|
|
19518
19530
|
|
|
19519
19531
|
秒数,默认 300 秒
|
|
19520
19532
|
|
|
@@ -20025,7 +20037,7 @@ lib/undici/type-aliases/THttpHeaders.md
|
|
|
20025
20037
|
|
|
20026
20038
|
> **THttpHeaders** = `http.IncomingHttpHeaders` & `object`
|
|
20027
20039
|
|
|
20028
|
-
Defined in: [lib/undici.ts:
|
|
20040
|
+
Defined in: [lib/undici.ts:932](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L932)
|
|
20029
20041
|
|
|
20030
20042
|
http headers
|
|
20031
20043
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.16.
|
|
9
|
+
export const VER = '9.16.2';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/db/conn.js
CHANGED
|
@@ -3,6 +3,7 @@ import * as lCore from '#kebab/lib/core.js';
|
|
|
3
3
|
import * as lTime from '#kebab/lib/time.js';
|
|
4
4
|
import * as lDb from '#kebab/lib/db.js';
|
|
5
5
|
import * as lSqlValue from '#kebab/lib/sql/value.js';
|
|
6
|
+
import * as lText from '#kebab/lib/text.js';
|
|
6
7
|
// --- 注册解析器 ---
|
|
7
8
|
// --- pg 库对以下类型默认返回 string,为与 MySQL 行为保持一致,在此注册解析器转为 JS 原生类型 ---
|
|
8
9
|
// --- POLYGON: 返回如 ((1,1),(2,2)) 的字符串,解析为 {x, y}[] ---
|
|
@@ -301,11 +302,16 @@ export class Connection {
|
|
|
301
302
|
}
|
|
302
303
|
return true;
|
|
303
304
|
}
|
|
304
|
-
catch {
|
|
305
|
+
catch (e) {
|
|
306
|
+
this._transaction = false;
|
|
307
|
+
this._using = false;
|
|
308
|
+
this._lost = true;
|
|
309
|
+
lCore.log({}, '[DB][Connection][beginTransaction] ' + lText.stringifyError(e), '-error');
|
|
305
310
|
return false;
|
|
306
311
|
}
|
|
307
312
|
}
|
|
308
313
|
else {
|
|
314
|
+
lCore.log({}, '[DB][Connection][beginTransaction] connection is not in use', '-error');
|
|
309
315
|
return false;
|
|
310
316
|
}
|
|
311
317
|
}
|
|
@@ -322,7 +328,9 @@ export class Connection {
|
|
|
322
328
|
this._using = false;
|
|
323
329
|
return true;
|
|
324
330
|
}
|
|
325
|
-
catch {
|
|
331
|
+
catch (e) {
|
|
332
|
+
this._lost = true;
|
|
333
|
+
lCore.log({}, '[DB][Connection][commit] ' + lText.stringifyError(e), '-error');
|
|
326
334
|
return false;
|
|
327
335
|
}
|
|
328
336
|
}
|
|
@@ -339,7 +347,9 @@ export class Connection {
|
|
|
339
347
|
this._using = false;
|
|
340
348
|
return true;
|
|
341
349
|
}
|
|
342
|
-
catch {
|
|
350
|
+
catch (e) {
|
|
351
|
+
this._lost = true;
|
|
352
|
+
lCore.log({}, '[DB][Connection][rollback] ' + lText.stringifyError(e), '-error');
|
|
343
353
|
return false;
|
|
344
354
|
}
|
|
345
355
|
}
|
package/lib/db/pool.js
CHANGED
|
@@ -8,6 +8,10 @@ import { Connection } from './conn.js';
|
|
|
8
8
|
import { Transaction } from './tran.js';
|
|
9
9
|
/** --- 连接列表池 --- */
|
|
10
10
|
const connections = [];
|
|
11
|
+
/** --- 开启事务最大尝试次数:首次尝试加一次换连接重试 --- */
|
|
12
|
+
const BEGIN_TRANSACTION_MAX_ATTEMPTS = 2;
|
|
13
|
+
/** --- 创建连接最大尝试次数:首次尝试加两次瞬时故障重试 --- */
|
|
14
|
+
const CREATE_CONNECTION_MAX_ATTEMPTS = 3;
|
|
11
15
|
/**
|
|
12
16
|
* --- 获取当前连接池中所有连接的信息 ---
|
|
13
17
|
*/
|
|
@@ -157,14 +161,19 @@ export class Pool {
|
|
|
157
161
|
* --- 开启事务,返回事务对象并锁定连接,别人任何人不可用,有 ctr 的话必传 this,独立执行时可传 null ---
|
|
158
162
|
*/
|
|
159
163
|
async beginTransaction(ctr) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
for (let i = 0; i < BEGIN_TRANSACTION_MAX_ATTEMPTS; ++i) {
|
|
165
|
+
const conn = await this._getConnection();
|
|
166
|
+
if (!conn) {
|
|
167
|
+
lCore.log(ctr ?? {}, `[DB][Pool][beginTransaction] failed to get connection, service: ${lDb.ESERVICE[this._service]}, database: ${this._etc.name ?? ''}`, '-error');
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
if (!await conn.beginTransaction()) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
return new Transaction(ctr, conn);
|
|
166
174
|
}
|
|
167
|
-
|
|
175
|
+
lCore.log(ctr ?? {}, `[DB][Pool][beginTransaction] failed after retry, service: ${lDb.ESERVICE[this._service]}, database: ${this._etc.name ?? ''}`, '-error');
|
|
176
|
+
return null;
|
|
168
177
|
}
|
|
169
178
|
/**
|
|
170
179
|
* --- 获取一个连接,自动变为 using 状态,;连接失败会返回 null ---
|
|
@@ -192,7 +201,7 @@ export class Pool {
|
|
|
192
201
|
}
|
|
193
202
|
if (!conn) {
|
|
194
203
|
// --- 没有找到合适的连接,创建一个 ---
|
|
195
|
-
loop: for (let i = 0; i <
|
|
204
|
+
loop: for (let i = 0; i < CREATE_CONNECTION_MAX_ATTEMPTS; ++i) {
|
|
196
205
|
try {
|
|
197
206
|
switch (this._service) {
|
|
198
207
|
case lDb.ESERVICE.MYSQL: {
|
|
@@ -267,12 +276,13 @@ export class Pool {
|
|
|
267
276
|
}
|
|
268
277
|
}
|
|
269
278
|
catch (err) {
|
|
270
|
-
|
|
271
|
-
|
|
279
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
280
|
+
const transient = ['ETIMEOUT', 'EHOSTUNREACH', 'ECONNREFUSED'].some(code => message.includes(code));
|
|
281
|
+
if (transient && i < CREATE_CONNECTION_MAX_ATTEMPTS - 1) {
|
|
272
282
|
await lCore.sleep(300);
|
|
273
283
|
continue;
|
|
274
284
|
}
|
|
275
|
-
const msg = `[DB][_getConnection][${lDb.ESERVICE[this._service]}] ${
|
|
285
|
+
const msg = `[DB][_getConnection][${lDb.ESERVICE[this._service]}] ${message}(${this._etc.host}:${this._etc.port})`;
|
|
276
286
|
lCore.debug(msg);
|
|
277
287
|
lCore.log({}, msg, '-error');
|
|
278
288
|
break;
|
package/lib/undici.d.ts
CHANGED
|
@@ -36,10 +36,11 @@ export declare function post(u: string, data: Record<string, kebab.Json> | Buffe
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function postJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<lResponse.Response>;
|
|
38
38
|
/**
|
|
39
|
-
* --- 发起 JSON 请求并解析 JSON
|
|
39
|
+
* --- 发起 JSON 请求并解析 JSON 响应 ---
|
|
40
40
|
* @param u 网址
|
|
41
41
|
* @param data 数据
|
|
42
42
|
* @param opt 选项
|
|
43
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
43
44
|
*/
|
|
44
45
|
export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
45
46
|
/**
|
|
@@ -47,14 +48,14 @@ export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Rec
|
|
|
47
48
|
* @param u 网址
|
|
48
49
|
* @param data 数据
|
|
49
50
|
* @param opt 选项
|
|
50
|
-
* @returns JSON
|
|
51
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
51
52
|
*/
|
|
52
53
|
export declare function postResponseJson(u: string, data: Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
53
54
|
/**
|
|
54
55
|
* --- 发起 GET 请求并解析 JSON 响应 ---
|
|
55
56
|
* @param u 网址
|
|
56
57
|
* @param opt 选项
|
|
57
|
-
* @returns JSON
|
|
58
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
58
59
|
*/
|
|
59
60
|
export declare function getResponseJson(u: string, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
60
61
|
/**
|
|
@@ -130,6 +131,8 @@ export interface IRequestOptions {
|
|
|
130
131
|
'timeout'?: number;
|
|
131
132
|
/** --- 网络异常后的重试次数,默认 0;流式请求体不可重试,非幂等请求需由调用方保证安全 --- */
|
|
132
133
|
'retry'?: number;
|
|
134
|
+
/** --- JSON 解析失败后的重试次数,默认 0;仅适用于 ResponseJson 快捷方法,非幂等请求需由调用方保证安全 --- */
|
|
135
|
+
'retryJson'?: number;
|
|
133
136
|
/** --- 追踪 location 次数,0 为不追踪,默认为 0 --- */
|
|
134
137
|
'follow'?: number;
|
|
135
138
|
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
package/lib/undici.js
CHANGED
|
@@ -32,6 +32,19 @@ const retryErrorCodes = [
|
|
|
32
32
|
'EHOSTDOWN', 'EHOSTUNREACH', 'EPIPE', 'ETIMEDOUT', 'UND_ERR_SOCKET',
|
|
33
33
|
'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT'
|
|
34
34
|
];
|
|
35
|
+
/** --- JSON 解析重试的初始等待时间,单位毫秒 --- */
|
|
36
|
+
const RETRY_JSON_MIN_TIMEOUT = 500;
|
|
37
|
+
/** --- JSON 解析重试的最大等待时间,单位毫秒 --- */
|
|
38
|
+
const RETRY_JSON_MAX_TIMEOUT = 30_000;
|
|
39
|
+
/**
|
|
40
|
+
* --- 将重试次数规范为非负整数 ---
|
|
41
|
+
* @param retry 重试次数
|
|
42
|
+
* @returns 可执行的重试次数
|
|
43
|
+
*/
|
|
44
|
+
function normalizeRetry(retry) {
|
|
45
|
+
return (typeof retry === 'number') && Number.isFinite(retry) ?
|
|
46
|
+
Math.max(0, Math.floor(retry)) : 0;
|
|
47
|
+
}
|
|
35
48
|
/** --- 获取或创建 undici.agent 对象 --- */
|
|
36
49
|
function getAgent(opt = {}) {
|
|
37
50
|
let k = opt.reuse ?? 'default';
|
|
@@ -74,8 +87,7 @@ function getAgent(opt = {}) {
|
|
|
74
87
|
*/
|
|
75
88
|
function getDispatcher(opt, method, data) {
|
|
76
89
|
const agent = getAgent(opt);
|
|
77
|
-
const retry = (
|
|
78
|
-
Math.max(0, Math.floor(opt.retry)) : 0;
|
|
90
|
+
const retry = normalizeRetry(opt.retry);
|
|
79
91
|
if ((retry === 0) || (data instanceof stream.Readable)) {
|
|
80
92
|
return agent;
|
|
81
93
|
}
|
|
@@ -123,74 +135,70 @@ export async function postJson(u, data, opt = {}) {
|
|
|
123
135
|
return request(u, data, opt);
|
|
124
136
|
}
|
|
125
137
|
/**
|
|
126
|
-
* ---
|
|
138
|
+
* --- 发起请求并解析 JSON 响应,可在解析失败时重新请求 ---
|
|
139
|
+
* @param u 网址
|
|
140
|
+
* @param data 请求数据
|
|
141
|
+
* @param opt 请求选项
|
|
142
|
+
* @param action 日志动作名
|
|
143
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
144
|
+
*/
|
|
145
|
+
async function requestResponseJson(u, data, opt, action) {
|
|
146
|
+
const retryJson = normalizeRetry(opt.retryJson);
|
|
147
|
+
for (let i = 0; i <= retryJson; ++i) {
|
|
148
|
+
const res = await request(u, data, opt);
|
|
149
|
+
const rtn = await res.getContent();
|
|
150
|
+
if (!rtn) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const rtnStr = rtn.toString();
|
|
154
|
+
const json = lText.parseJson(rtnStr);
|
|
155
|
+
if (json) {
|
|
156
|
+
return json;
|
|
157
|
+
}
|
|
158
|
+
if (i < retryJson) {
|
|
159
|
+
const timeout = Math.min(RETRY_JSON_MIN_TIMEOUT * (2 ** i), RETRY_JSON_MAX_TIMEOUT);
|
|
160
|
+
await lCore.sleep(timeout);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (opt.log === undefined || opt.log) {
|
|
164
|
+
const requestData = data === undefined ? '' : `, data: ${lText.stringifyJson(data)}`;
|
|
165
|
+
lCore.log({}, `[UNDICI][${action}] parse json failed, url: ${u}${requestData}, content: ${rtnStr}`, '-neterror');
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* --- 发起 JSON 请求并解析 JSON 响应 ---
|
|
127
173
|
* @param u 网址
|
|
128
174
|
* @param data 数据
|
|
129
175
|
* @param opt 选项
|
|
176
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
130
177
|
*/
|
|
131
178
|
export async function postJsonResponseJson(u, data, opt = {}) {
|
|
132
179
|
opt.method = 'POST';
|
|
133
180
|
opt.type = 'json';
|
|
134
|
-
|
|
135
|
-
const rtn = await res.getContent();
|
|
136
|
-
if (!rtn) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const rtnStr = rtn.toString();
|
|
140
|
-
const json = lText.parseJson(rtnStr);
|
|
141
|
-
if (!json) {
|
|
142
|
-
if (opt.log === undefined || opt.log) {
|
|
143
|
-
lCore.log({}, `[UNDICI][POSTJSONRESPONSEJSON] parse json failed, url: ${u}, data: ${lText.stringifyJson(data)}, content: ${rtnStr}`, '-neterror');
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return json;
|
|
181
|
+
return requestResponseJson(u, data, opt, 'POSTJSONRESPONSEJSON');
|
|
148
182
|
}
|
|
149
183
|
/**
|
|
150
184
|
* --- 发起 POST 请求并解析 JSON 响应 ---
|
|
151
185
|
* @param u 网址
|
|
152
186
|
* @param data 数据
|
|
153
187
|
* @param opt 选项
|
|
154
|
-
* @returns JSON
|
|
188
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
155
189
|
*/
|
|
156
190
|
export async function postResponseJson(u, data, opt = {}) {
|
|
157
191
|
opt.method = 'POST';
|
|
158
|
-
|
|
159
|
-
const rtn = await res.getContent();
|
|
160
|
-
if (!rtn) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
const rtnStr = rtn.toString();
|
|
164
|
-
const json = lText.parseJson(rtnStr);
|
|
165
|
-
if (!json) {
|
|
166
|
-
if (opt.log === undefined || opt.log) {
|
|
167
|
-
lCore.log({}, `[UNDICI][POSTRESPONSEJSON] parse json failed, url: ${u}, data: ${lText.stringifyJson(data)}, content: ${rtnStr}`, '-neterror');
|
|
168
|
-
}
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
return json;
|
|
192
|
+
return requestResponseJson(u, data, opt, 'POSTRESPONSEJSON');
|
|
172
193
|
}
|
|
173
194
|
/**
|
|
174
195
|
* --- 发起 GET 请求并解析 JSON 响应 ---
|
|
175
196
|
* @param u 网址
|
|
176
197
|
* @param opt 选项
|
|
177
|
-
* @returns JSON
|
|
198
|
+
* @returns JSON 数据;请求失败返回 null;JSON 解析失败返回 false
|
|
178
199
|
*/
|
|
179
200
|
export async function getResponseJson(u, opt = {}) {
|
|
180
|
-
|
|
181
|
-
const rtn = await res.getContent();
|
|
182
|
-
if (!rtn) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
const rtnStr = rtn.toString();
|
|
186
|
-
const json = lText.parseJson(rtnStr);
|
|
187
|
-
if (!json) {
|
|
188
|
-
if (opt.log === undefined || opt.log) {
|
|
189
|
-
lCore.log({}, `[UNDICI][GETRESPONSEJSON] parse json failed, url: ${u}, content: ${rtnStr}`, '-neterror');
|
|
190
|
-
}
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
return json;
|
|
201
|
+
return requestResponseJson(u, undefined, opt, 'GETRESPONSEJSON');
|
|
194
202
|
}
|
|
195
203
|
/**
|
|
196
204
|
* --- 发起一个完全兼容 fetch 的请求 ---
|
package/package.json
CHANGED
package/sys/route.js
CHANGED
|
@@ -175,7 +175,7 @@ export async function run(data) {
|
|
|
175
175
|
path = '@';
|
|
176
176
|
}
|
|
177
177
|
/** --- 不做语言跳转、不进入动态处理流程的路径 --- */
|
|
178
|
-
const stcPaths = /^(stc\/.*|favicon.\w+?\??.*|apple[\w-]+?\.png\??.*|[\w-]+?\.txt
|
|
178
|
+
const stcPaths = /^(stc\/.*|favicon.\w+?\??.*|apple[\w-]+?\.png\??.*|[\w-]+?\.(?:txt|html|xml)\??.*)/;
|
|
179
179
|
// --- 检测是否托管语言页面 ---
|
|
180
180
|
const param = [];
|
|
181
181
|
if (config.lang && data.res && !stcPaths.test(path)) {
|