node-easywechat 3.1.0 → 3.1.1
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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v3.1.1 (2022-11-15)
|
|
5
|
+
|
|
6
|
+
- Feat: 增加请求失败时的重试机制,具体见配置项http.retry
|
|
7
|
+
|
|
4
8
|
## v3.1.0 (2022-11-09)
|
|
5
9
|
|
|
6
10
|
- Feat: 新增开放平台模块
|
|
@@ -9,6 +13,8 @@
|
|
|
9
13
|
- Fix: 修复配置项类型判断异常的问题
|
|
10
14
|
- Fix: 修复请求客户端无法设置请求是否错误判断逻辑的方法
|
|
11
15
|
|
|
16
|
+
- Docs: 增加开放平台的说明
|
|
17
|
+
|
|
12
18
|
- Perf: 优化url路径解析方法
|
|
13
19
|
|
|
14
20
|
## v3.0.1 (2022-08-26)
|
package/README.md
CHANGED
|
@@ -78,7 +78,11 @@ let data = response.toObject();
|
|
|
78
78
|
{
|
|
79
79
|
// axios 请求参数
|
|
80
80
|
// 详见:https://github.com/axios/axios#request-config
|
|
81
|
-
http: {
|
|
81
|
+
http: {
|
|
82
|
+
// 请求失败时,自动重试。默认不重试
|
|
83
|
+
// 详见:https://github.com/softonic/axios-retry#options
|
|
84
|
+
retry: {}
|
|
85
|
+
},
|
|
82
86
|
|
|
83
87
|
// 缓存以文件(默认设置)存储时,需要的配置项
|
|
84
88
|
file_cache: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method } from 'axios';
|
|
2
2
|
import HttpClientInterface from './Contracts/HttpClientInterface';
|
|
3
3
|
import HttpClientResponse from './HttpClientResponse';
|
|
4
|
-
import { HttpClientFailureJudgeClosure, LogHandler } from '../../Types/global';
|
|
4
|
+
import { HttpClientFailureJudgeClosure, HttpConfig, LogHandler } from '../../Types/global';
|
|
5
5
|
import FormData from 'form-data';
|
|
6
6
|
declare class HttpClient implements HttpClientInterface {
|
|
7
7
|
protected axios: AxiosInstance;
|
|
@@ -28,6 +28,6 @@ declare class HttpClient implements HttpClientInterface {
|
|
|
28
28
|
* @param config
|
|
29
29
|
* @returns
|
|
30
30
|
*/
|
|
31
|
-
static create(config?:
|
|
31
|
+
static create(config?: HttpConfig, failureJudge?: HttpClientFailureJudgeClosure, throwError?: boolean): HttpClient;
|
|
32
32
|
}
|
|
33
33
|
export = HttpClient;
|
|
@@ -15,6 +15,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
15
15
|
const HttpClientResponse_1 = __importDefault(require("./HttpClientResponse"));
|
|
16
16
|
const Utils_1 = require("../Support/Utils");
|
|
17
17
|
const form_data_1 = __importDefault(require("form-data"));
|
|
18
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
18
19
|
class HttpClient {
|
|
19
20
|
constructor(axios, failureJudge = null, throwError = false) {
|
|
20
21
|
this.axios = axios;
|
|
@@ -139,7 +140,11 @@ class HttpClient {
|
|
|
139
140
|
* @returns
|
|
140
141
|
*/
|
|
141
142
|
static create(config = null, failureJudge = null, throwError = false) {
|
|
142
|
-
|
|
143
|
+
let axios = axios_1.default.create(config);
|
|
144
|
+
if (config && config.retry) {
|
|
145
|
+
(0, axios_retry_1.default)(axios, config.retry);
|
|
146
|
+
}
|
|
147
|
+
return new HttpClient(axios, failureJudge, throwError);
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
module.exports = HttpClient;
|
package/dist/Types/global.d.ts
CHANGED
|
@@ -74,6 +74,35 @@ export declare interface CacheFileConfig {
|
|
|
74
74
|
ext: string
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* 网络请求配置
|
|
79
|
+
*/
|
|
80
|
+
export declare interface HttpConfig extends AxiosRequestConfig {
|
|
81
|
+
/**
|
|
82
|
+
* 是否抛出异常
|
|
83
|
+
*/
|
|
84
|
+
throw?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* 是否抛出异常
|
|
87
|
+
* @see https://github.com/softonic/axios-retry#options
|
|
88
|
+
*/
|
|
89
|
+
retry?: IAxiosRetry.IAxiosRetryConfig;
|
|
90
|
+
// retry?: {
|
|
91
|
+
// /**
|
|
92
|
+
// * 仅以下状态码重试
|
|
93
|
+
// */
|
|
94
|
+
// http_codes: number[];
|
|
95
|
+
// /**
|
|
96
|
+
// * 最大重试次数
|
|
97
|
+
// */
|
|
98
|
+
// max_retries: number;
|
|
99
|
+
// /**
|
|
100
|
+
// * 请求间隔 (毫秒)
|
|
101
|
+
// */
|
|
102
|
+
// delay: number;
|
|
103
|
+
// };
|
|
104
|
+
}
|
|
105
|
+
|
|
77
106
|
/**
|
|
78
107
|
* 基础配置
|
|
79
108
|
*/
|
|
@@ -81,7 +110,7 @@ export declare interface BaseConfig {
|
|
|
81
110
|
/**
|
|
82
111
|
* 网络请求相关配置
|
|
83
112
|
*/
|
|
84
|
-
http?:
|
|
113
|
+
http?: HttpConfig;
|
|
85
114
|
|
|
86
115
|
/**
|
|
87
116
|
* 文件缓存相关配置
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-easywechat",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
"@types/node": "^17.0.23",
|
|
23
23
|
"axios-mock-adapter": "^1.21.1",
|
|
24
24
|
"mocha": "^9.2.2",
|
|
25
|
-
"package-release": "^1.0.
|
|
25
|
+
"package-release": "^1.0.3",
|
|
26
26
|
"typescript": "^4.6.3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"axios": "^0.26.1",
|
|
30
|
+
"axios-retry": "^3.3.1",
|
|
30
31
|
"form-data": "^4.0.0",
|
|
31
32
|
"merge": "^2.1.1",
|
|
32
33
|
"node-socialite": "^1.2.5",
|