@ekhein/http-request 1.0.15 → 1.0.17
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 +0 -1
- package/dist/main.js +0 -29
- package/dist/proxy/phone4g.proxy.js +1 -3
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare class HttpRequest {
|
|
|
8
8
|
execute<R = any>(options: HttpRequestConfig): Promise<R>;
|
|
9
9
|
post<R = any>(url: string, data?: any, opts?: HttpRequestConfig): Promise<R>;
|
|
10
10
|
invoke<R = any>(path: string, data: object, opts?: HttpRequestConfig): Promise<R>;
|
|
11
|
-
call<R = any>(url: string, args?: Array<any>, opts?: HttpRequestConfig): Promise<R>;
|
|
12
11
|
}
|
|
13
12
|
export * from './libs';
|
|
14
13
|
export * from './exceptions';
|
package/dist/main.js
CHANGED
|
@@ -165,17 +165,6 @@ class HttpRequest {
|
|
|
165
165
|
request.baseURL = String(process.env.CORE_URL);
|
|
166
166
|
if (request.serviceType == 2)
|
|
167
167
|
request.baseURL = String(process.env.SEKIRO_URL);
|
|
168
|
-
if (request.serviceType == 3)
|
|
169
|
-
request.baseURL = String("http://*:65000/script").replace("*", request.clientIp);
|
|
170
|
-
return request;
|
|
171
|
-
}));
|
|
172
|
-
/* Validate Status */
|
|
173
|
-
this.instance.interceptors.request.use((request) => __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
if (request.serviceType == 1) { }
|
|
175
|
-
if (request.serviceType == 2) { }
|
|
176
|
-
if (request.serviceType == 3) {
|
|
177
|
-
request.validateStatus = status => [200, 410, 500, 400].includes(status);
|
|
178
|
-
}
|
|
179
168
|
return request;
|
|
180
169
|
}));
|
|
181
170
|
/* Transform */
|
|
@@ -188,10 +177,6 @@ class HttpRequest {
|
|
|
188
177
|
request.url = String("/business-demo/invoke");
|
|
189
178
|
request.params = Object({ group, action, invoke_timeout });
|
|
190
179
|
}
|
|
191
|
-
if (request.serviceType == 3) {
|
|
192
|
-
const args = JSON.stringify(request.args);
|
|
193
|
-
request.form = Object({ args });
|
|
194
|
-
}
|
|
195
180
|
return request;
|
|
196
181
|
}));
|
|
197
182
|
/* Call Custom Hook */
|
|
@@ -217,14 +202,6 @@ class HttpRequest {
|
|
|
217
202
|
throw new common_1.ServiceUnavailableException(response.data.message);
|
|
218
203
|
return response.data.data;
|
|
219
204
|
}
|
|
220
|
-
if (response.config.serviceType == 3) {
|
|
221
|
-
if (response.status == 200)
|
|
222
|
-
return response.data.result;
|
|
223
|
-
const exception = String(response.data.exception);
|
|
224
|
-
const reason = Array.from(response.data.args).at(0);
|
|
225
|
-
const message = Array.from([exception, reason]).join("::");
|
|
226
|
-
throw new common_1.ServiceUnavailableException(message);
|
|
227
|
-
}
|
|
228
205
|
if (response.config.html) {
|
|
229
206
|
return new jsdom_1.JSDOM(response.data);
|
|
230
207
|
}
|
|
@@ -281,12 +258,6 @@ class HttpRequest {
|
|
|
281
258
|
.request(Object.assign(Object.assign({}, opts), { method: "POST", serviceType: 2, data, path }));
|
|
282
259
|
});
|
|
283
260
|
}
|
|
284
|
-
call(url_1) {
|
|
285
|
-
return __awaiter(this, arguments, void 0, function* (url, args = [], opts = {}) {
|
|
286
|
-
return this.instance
|
|
287
|
-
.request(Object.assign(Object.assign({}, opts), { method: "POST", serviceType: 3, args, url }));
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
261
|
}
|
|
291
262
|
exports.HttpRequest = HttpRequest;
|
|
292
263
|
__exportStar(require("./libs"), exports);
|
|
@@ -6,9 +6,7 @@ class Phone4GProxy extends proxy_agent_1.ProxyAgent {
|
|
|
6
6
|
constructor(opts) {
|
|
7
7
|
super({
|
|
8
8
|
getProxyForUrl: () => {
|
|
9
|
-
|
|
10
|
-
const usbcom = String(opts.clientIp).split(".").at(-1);
|
|
11
|
-
return ("http://172.16.1.1:3".concat(subnet, usbcom));
|
|
9
|
+
return ("http://*:65000".replace("*", opts.clientIp));
|
|
12
10
|
},
|
|
13
11
|
});
|
|
14
12
|
}
|