@modern-js/create-request 2.20.0 → 2.20.1-alpha.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.
@@ -19,7 +19,14 @@ const _querystring = /* @__PURE__ */ _interop_require_default._(require("query-s
19
19
  const _handleRes = require("./handleRes");
20
20
  let realRequest;
21
21
  let realAllowedHeaders;
22
- const originFetch = (...params) => fetch(...params).then(_handleRes.handleRes);
22
+ const originFetch = (...params) => {
23
+ var _init_method;
24
+ const [url, init] = params;
25
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
26
+ init.body = void 0;
27
+ }
28
+ return fetch(url, init).then(_handleRes.handleRes);
29
+ };
23
30
  const configure = (options) => {
24
31
  const { request, interceptor, allowedHeaders } = options;
25
32
  realRequest = request || originFetch;
@@ -87,9 +94,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
87
94
  }
88
95
  }
89
96
  }
90
- if (method.toLowerCase() === "get") {
91
- body = void 0;
92
- }
93
97
  headers.accept = `application/json,*/*;q=0.8`;
94
98
  return fetcher(finalURL, {
95
99
  method,
package/dist/cjs/node.js CHANGED
@@ -21,7 +21,14 @@ const _querystring = /* @__PURE__ */ _interop_require_default._(require("query-s
21
21
  const _handleRes = require("./handleRes");
22
22
  let realRequest;
23
23
  let realAllowedHeaders = [];
24
- const originFetch = (...params) => (0, _nodefetch.default)(...params).then(_handleRes.handleRes);
24
+ const originFetch = (...params) => {
25
+ var _init_method;
26
+ const [, init] = params;
27
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
28
+ init.body = void 0;
29
+ }
30
+ return (0, _nodefetch.default)(...params).then(_handleRes.handleRes);
31
+ };
25
32
  const configure = (options) => {
26
33
  const { request, interceptor, allowedHeaders } = options;
27
34
  realRequest = request || originFetch;
@@ -89,9 +96,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
89
96
  }
90
97
  url = `http://localhost:${port}${finalPath}`;
91
98
  }
92
- if (method.toLowerCase() === "get") {
93
- body = void 0;
94
- }
95
99
  const fetcher = realRequest || originFetch;
96
100
  if (method.toLowerCase() === "get") {
97
101
  body = void 0;
@@ -1,6 +1,6 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import { compile, pathToRegexp } from "path-to-regexp";
6
6
  import qs from "query-string";
@@ -11,7 +11,12 @@ var originFetch = function() {
11
11
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
12
12
  params[_key] = arguments[_key];
13
13
  }
14
- return fetch.apply(void 0, _to_consumable_array(params)).then(handleRes);
14
+ var _init_method;
15
+ var _params = _sliced_to_array(params, 2), url = _params[0], init = _params[1];
16
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
17
+ init.body = void 0;
18
+ }
19
+ return fetch(url, init).then(handleRes);
15
20
  };
16
21
  export var configure = function(options) {
17
22
  var request = options.request, interceptor = options.interceptor, allowedHeaders = options.allowedHeaders;
@@ -85,9 +90,6 @@ export var createRequest = function(path, method, port) {
85
90
  }
86
91
  }
87
92
  }
88
- if (method.toLowerCase() === "get") {
89
- body = void 0;
90
- }
91
93
  headers.accept = "application/json,*/*;q=0.8";
92
94
  return [
93
95
  2,
package/dist/esm/node.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
1
2
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
3
  import nodeFetch from "node-fetch";
3
4
  import { compile, pathToRegexp } from "path-to-regexp";
@@ -10,6 +11,11 @@ var originFetch = function() {
10
11
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
11
12
  params[_key] = arguments[_key];
12
13
  }
14
+ var _init_method;
15
+ var _params = _sliced_to_array(params, 2), init = _params[1];
16
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
17
+ init.body = void 0;
18
+ }
13
19
  return nodeFetch.apply(void 0, _to_consumable_array(params)).then(handleRes);
14
20
  };
15
21
  export var configure = function(options) {
@@ -100,9 +106,6 @@ export var createRequest = function(path, method, port) {
100
106
  }
101
107
  url = "http://localhost:".concat(port).concat(finalPath);
102
108
  }
103
- if (method.toLowerCase() === "get") {
104
- body = void 0;
105
- }
106
109
  var fetcher = realRequest || originFetch;
107
110
  if (method.toLowerCase() === "get") {
108
111
  body = void 0;
@@ -3,7 +3,14 @@ import qs from "query-string";
3
3
  import { handleRes } from "./handleRes";
4
4
  let realRequest;
5
5
  let realAllowedHeaders;
6
- const originFetch = (...params) => fetch(...params).then(handleRes);
6
+ const originFetch = (...params) => {
7
+ var _init_method;
8
+ const [url, init] = params;
9
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
10
+ init.body = void 0;
11
+ }
12
+ return fetch(url, init).then(handleRes);
13
+ };
7
14
  export const configure = (options) => {
8
15
  const { request, interceptor, allowedHeaders } = options;
9
16
  realRequest = request || originFetch;
@@ -71,9 +78,6 @@ export const createRequest = (path, method, port, httpMethodDecider = "functionN
71
78
  }
72
79
  }
73
80
  }
74
- if (method.toLowerCase() === "get") {
75
- body = void 0;
76
- }
77
81
  headers.accept = `application/json,*/*;q=0.8`;
78
82
  return fetcher(finalURL, {
79
83
  method,
@@ -5,7 +5,14 @@ import qs from "query-string";
5
5
  import { handleRes } from "./handleRes";
6
6
  let realRequest;
7
7
  let realAllowedHeaders = [];
8
- const originFetch = (...params) => nodeFetch(...params).then(handleRes);
8
+ const originFetch = (...params) => {
9
+ var _init_method;
10
+ const [, init] = params;
11
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
12
+ init.body = void 0;
13
+ }
14
+ return nodeFetch(...params).then(handleRes);
15
+ };
9
16
  export const configure = (options) => {
10
17
  const { request, interceptor, allowedHeaders } = options;
11
18
  realRequest = request || originFetch;
@@ -73,9 +80,6 @@ export const createRequest = (path, method, port, httpMethodDecider = "functionN
73
80
  }
74
81
  url = `http://localhost:${port}${finalPath}`;
75
82
  }
76
- if (method.toLowerCase() === "get") {
77
- body = void 0;
78
- }
79
83
  const fetcher = realRequest || originFetch;
80
84
  if (method.toLowerCase() === "get") {
81
85
  body = void 0;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.20.0",
18
+ "version": "2.20.1-alpha.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -73,9 +73,9 @@
73
73
  "isomorphic-fetch": "^3.0.0",
74
74
  "jest": "^29",
75
75
  "nock": "^13.2.1",
76
- "typescript": "^4",
77
- "@modern-js/types": "2.20.0",
76
+ "typescript": "^5",
78
77
  "@scripts/build": "2.20.0",
78
+ "@modern-js/types": "2.20.0",
79
79
  "@scripts/jest-config": "2.20.0"
80
80
  },
81
81
  "sideEffects": false,