@ekhein/http-request 2.0.5 → 2.0.7

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.
@@ -7,5 +7,5 @@ export declare class HttpRequest {
7
7
  post<R = any>(url: string, data?: any, opts?: HttpRequestConfig): Promise<R>;
8
8
  invoke<R = any>(path: string, data: object, opts?: HttpRequestConfig): Promise<R>;
9
9
  hook<R = any>(url: string, args: ArrayLike<any>, opts?: HttpRequestConfig): Promise<R>;
10
- call<R = any>(method: string, params: ArrayLike<any>, opts?: HttpRequestConfig): Promise<R>;
10
+ call<R = any>(method: string, args: ArrayLike<any>, opts?: HttpRequestConfig): Promise<R>;
11
11
  }
@@ -162,8 +162,9 @@ class HttpRequest {
162
162
  }));
163
163
  /* Transform */
164
164
  this.instance.interceptors.request.use((request) => __awaiter(this, void 0, void 0, function* () {
165
+ var _a;
165
166
  if (request.serviceType == 1) {
166
- request.baseURL = String(process.env.CORE_URL);
167
+ request.baseURL = String((_a = request.baseURL) !== null && _a !== void 0 ? _a : process.env.CORE_URL);
167
168
  }
168
169
  if (request.serviceType == 2) {
169
170
  const group = (0, path_to_regexp_1.compile)(request.path)(request.params).split("/").at(-2);
@@ -182,6 +183,7 @@ class HttpRequest {
182
183
  }
183
184
  if (request.serviceType == 4) {
184
185
  request.baseURL = String(`http://${request.clientIp}:65001/`);
186
+ request.body.params = Array.from(request.args);
185
187
  request.body.jsonrpc = String("2.0");
186
188
  request.body.id = (0, crypto_1.randomUUID)();
187
189
  }
@@ -250,10 +252,10 @@ class HttpRequest {
250
252
  .request(Object.assign(Object.assign({}, opts), { method: "POST", serviceType: 3, args, url }));
251
253
  });
252
254
  }
253
- call(method_1, params_1) {
254
- return __awaiter(this, arguments, void 0, function* (method, params, opts = {}) {
255
+ call(method_1, args_1) {
256
+ return __awaiter(this, arguments, void 0, function* (method, args, opts = {}) {
255
257
  return this.instance
256
- .request(Object.assign(Object.assign({}, opts), { method: "POST", serviceType: 4, body: { method, params } }));
258
+ .request(Object.assign(Object.assign({}, opts), { method: "POST", serviceType: 4, args, body: { method } }));
257
259
  });
258
260
  }
259
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/http-request",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "license": "MIT",
5
5
  "author": "ekhein",
6
6
  "main": "./dist/index.js",