@ekhein/http-request 1.0.0 → 1.0.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/dist/main.d.ts +2 -0
- package/dist/main.js +4 -0
- package/package.json +1 -1
- package/types/axios.d.ts +3 -40
- package/types/http-request.d.ts +47 -0
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
export * from './exceptions';
|
|
3
|
+
export type { HttpRequestConfig, HttpServiceTypes, HttpLiuGuanProxy, HttpPhone4GProxy, } from '../types/http-request';
|
|
2
4
|
export declare class HttpRequest {
|
|
3
5
|
readonly instance: AxiosInstance;
|
|
4
6
|
constructor(options: AxiosRequestConfig);
|
package/dist/main.js
CHANGED
|
@@ -32,6 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.HttpRequest = void 0;
|
|
37
40
|
const axios_1 = __importStar(require("axios"));
|
|
@@ -46,6 +49,7 @@ const agent_1 = require("./agent");
|
|
|
46
49
|
const agent_2 = require("./agent");
|
|
47
50
|
const agent_3 = require("./agent");
|
|
48
51
|
const exceptions_1 = require("./exceptions");
|
|
52
|
+
__exportStar(require("./exceptions"), exports);
|
|
49
53
|
class HttpRequest {
|
|
50
54
|
instance;
|
|
51
55
|
constructor(options) {
|
package/package.json
CHANGED
package/types/axios.d.ts
CHANGED
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CookieJar } from "tough-cookie"
|
|
1
|
+
import { ExtendAxiosRequestConfig } from "./http-request"
|
|
3
2
|
|
|
4
3
|
declare module "axios" {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[key: string]: any
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface LiuGuanProxyOptions {
|
|
11
|
-
adcode?: string
|
|
12
|
-
visitorId?: string
|
|
13
|
-
unbindTime?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface Phone4GProxyOptions {
|
|
17
|
-
clientIp: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface AxiosServiceTypes {
|
|
21
|
-
NATIVE: 1
|
|
22
|
-
SEKIRO: 2
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface AxiosRequestConfig extends AxiosRequestAnyConfig{
|
|
26
|
-
form?: any
|
|
27
|
-
body?: any
|
|
28
|
-
html?: boolean
|
|
29
|
-
resolveBodyOnly?: boolean
|
|
30
|
-
retryLimit?: number
|
|
31
|
-
serviceType?: AxiosServiceTypes[keyof AxiosServiceTypes]
|
|
32
|
-
useProxy?: boolean | LiuGuanProxyOptions | Phone4GProxyOptions
|
|
33
|
-
jar?: CookieJar
|
|
34
|
-
interceptorHooks?: {
|
|
35
|
-
requestInterceptor?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>
|
|
36
|
-
requestInterceptorCatch?: (error: any) => any
|
|
37
|
-
respondInterceptor?: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse | any>
|
|
38
|
-
respondInterceptorCatch?: (error: any) => any
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
4
|
+
interface AxiosRequestConfig extends ExtendAxiosRequestConfig {}
|
|
5
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AxiosRequestConfig, InternalAxiosRequestConfig, AxiosResponse, AxiosRequestHeaders } from "axios"
|
|
2
|
+
import { CookieJar } from "tough-cookie"
|
|
3
|
+
|
|
4
|
+
export interface HttpLiuGuanProxy {
|
|
5
|
+
adcode?: string
|
|
6
|
+
visitorId?: string
|
|
7
|
+
unbindTime?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HttpPhone4GProxy {
|
|
11
|
+
clientIp: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface HttpServiceTypes {
|
|
15
|
+
NATIVE: 1
|
|
16
|
+
SEKIRO: 2
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ExtendInternalAxiosRequestConfig extends HttpRequestConfig, InternalAxiosRequestConfig {
|
|
20
|
+
headers: AxiosRequestHeaders;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ExtendAxiosResponse extends AxiosResponse {
|
|
24
|
+
config: ExtendInternalAxiosRequestConfig
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ExtendAxiosRequestConfig extends Record<string, any> {
|
|
28
|
+
form?: any
|
|
29
|
+
body?: any
|
|
30
|
+
html?: boolean
|
|
31
|
+
resolveBodyOnly?: boolean
|
|
32
|
+
retryLimit?: number
|
|
33
|
+
serviceType?: HttpServiceTypes[keyof HttpServiceTypes]
|
|
34
|
+
useProxy?: boolean | HttpLiuGuanProxy | HttpPhone4GProxy
|
|
35
|
+
jar?: CookieJar
|
|
36
|
+
interceptorHooks?: {
|
|
37
|
+
requestInterceptor?: (config: ExtendInternalAxiosRequestConfig) => ExtendInternalAxiosRequestConfig | Promise<ExtendInternalAxiosRequestConfig>
|
|
38
|
+
requestInterceptorCatch?: (error: any) => any
|
|
39
|
+
respondInterceptor?: (response: ExtendAxiosResponse) => ExtendAxiosResponse | Promise<ExtendAxiosResponse | any>
|
|
40
|
+
respondInterceptorCatch?: (error: any) => any
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface HttpRequestConfig extends AxiosRequestConfig, ExtendAxiosRequestConfig {
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|