@modern-js/create-request 2.10.0 → 2.12.0
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/cjs/browser.js +1 -0
- package/dist/cjs/node.js +1 -0
- package/dist/esm/browser.js +1 -0
- package/dist/esm/node.js +1 -0
- package/dist/esm-node/browser.js +1 -0
- package/dist/esm-node/node.js +1 -0
- package/dist/types/node.d.ts +1 -1
- package/dist/types/types.d.ts +4 -6
- package/package.json +5 -5
- package/dist/cjs/index.js +0 -29
- package/dist/esm/index.js +0 -36
- package/dist/esm-node/index.js +0 -8
- package/dist/types/index.d.ts +0 -4
package/dist/cjs/browser.js
CHANGED
package/dist/cjs/node.js
CHANGED
|
@@ -111,6 +111,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
111
111
|
if (method.toLowerCase() === "get") {
|
|
112
112
|
body = void 0;
|
|
113
113
|
}
|
|
114
|
+
headers.accept = `application/json,*/*;q=0.8`;
|
|
114
115
|
return fetcher(url, { method, body, headers });
|
|
115
116
|
};
|
|
116
117
|
return sender;
|
package/dist/esm/browser.js
CHANGED
package/dist/esm/node.js
CHANGED
package/dist/esm-node/browser.js
CHANGED
package/dist/esm-node/node.js
CHANGED
|
@@ -78,6 +78,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
|
|
|
78
78
|
if (method.toLowerCase() === "get") {
|
|
79
79
|
body = void 0;
|
|
80
80
|
}
|
|
81
|
+
headers.accept = `application/json,*/*;q=0.8`;
|
|
81
82
|
return fetcher(url, { method, body, headers });
|
|
82
83
|
};
|
|
83
84
|
return sender;
|
package/dist/types/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import nodeFetch from 'node-fetch';
|
|
2
2
|
import type { RequestCreator, IOptions } from './types';
|
|
3
3
|
export declare const configure: (options: IOptions<typeof nodeFetch>) => void;
|
|
4
|
-
export declare const createRequest: RequestCreator
|
|
4
|
+
export declare const createRequest: RequestCreator<typeof nodeFetch>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type nodeFetch from 'node-fetch';
|
|
2
1
|
import type { HttpMethodDecider } from '@modern-js/types';
|
|
3
2
|
export type BFFRequestPayload = {
|
|
4
3
|
params?: Record<string, any>;
|
|
@@ -10,12 +9,11 @@ export type BFFRequestPayload = {
|
|
|
10
9
|
headers?: Record<string, any>;
|
|
11
10
|
cookies?: Record<string, any>;
|
|
12
11
|
};
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
fetch?: Fetch;
|
|
12
|
+
export type Sender<F = typeof fetch> = ((...args: any[]) => Promise<any>) & {
|
|
13
|
+
fetch?: F;
|
|
16
14
|
};
|
|
17
|
-
export type RequestCreator = (path: string, method: string, port: number, httpMethodDecider: HttpMethodDecider, fetch?:
|
|
18
|
-
export type IOptions<F =
|
|
15
|
+
export type RequestCreator<F = typeof fetch> = (path: string, method: string, port: number, httpMethodDecider: HttpMethodDecider, fetch?: F) => Sender;
|
|
16
|
+
export type IOptions<F = typeof fetch> = {
|
|
19
17
|
request?: F;
|
|
20
18
|
interceptor?: (request: F) => F;
|
|
21
19
|
allowedHeaders?: string[];
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.12.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"node-fetch": "^2.6.1",
|
|
61
61
|
"path-to-regexp": "^6.2.0",
|
|
62
62
|
"query-string": "^7.1.1",
|
|
63
|
-
"@modern-js/utils": "2.
|
|
63
|
+
"@modern-js/utils": "2.12.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/jest": "^29",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"jest": "^29",
|
|
71
71
|
"nock": "^13.2.1",
|
|
72
72
|
"typescript": "^4",
|
|
73
|
-
"@modern-js/types": "2.
|
|
74
|
-
"@scripts/build": "2.
|
|
75
|
-
"@scripts/jest-config": "2.
|
|
73
|
+
"@modern-js/types": "2.12.0",
|
|
74
|
+
"@scripts/build": "2.12.0",
|
|
75
|
+
"@scripts/jest-config": "2.12.0"
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
78
|
"publishConfig": {
|
package/dist/cjs/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var src_exports = {};
|
|
19
|
-
__export(src_exports, {
|
|
20
|
-
default: () => src_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(src_exports);
|
|
23
|
-
var import_utils = require("@modern-js/utils");
|
|
24
|
-
var import_browser = require("./browser");
|
|
25
|
-
var import_node = require("./node");
|
|
26
|
-
const createRequest = (...args) => (0, import_utils.isBrowser)() ? (0, import_browser.createRequest)(...args) : (0, import_node.createRequest)(...args);
|
|
27
|
-
var src_default = createRequest;
|
|
28
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
-
0 && (module.exports = {});
|
package/dist/esm/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _arrayWithoutHoles(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
|
-
}
|
|
9
|
-
function _iterableToArray(iter) {
|
|
10
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
-
}
|
|
12
|
-
function _nonIterableSpread() {
|
|
13
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
-
}
|
|
15
|
-
function _toConsumableArray(arr) {
|
|
16
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
17
|
-
}
|
|
18
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
19
|
-
if (!o) return;
|
|
20
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
21
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
|
-
}
|
|
26
|
-
import { isBrowser } from "@modern-js/utils";
|
|
27
|
-
import { createRequest as browser } from "./browser";
|
|
28
|
-
import { createRequest as node } from "./node";
|
|
29
|
-
var createRequest = function() {
|
|
30
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
31
|
-
args[_key] = arguments[_key];
|
|
32
|
-
}
|
|
33
|
-
return isBrowser() ? browser.apply(void 0, _toConsumableArray(args)) : node.apply(void 0, _toConsumableArray(args));
|
|
34
|
-
};
|
|
35
|
-
var src_default = createRequest;
|
|
36
|
-
export { src_default as default };
|
package/dist/esm-node/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from "@modern-js/utils";
|
|
2
|
-
import { createRequest as browser } from "./browser";
|
|
3
|
-
import { createRequest as node } from "./node";
|
|
4
|
-
const createRequest = (...args) => isBrowser() ? browser(...args) : node(...args);
|
|
5
|
-
var src_default = createRequest;
|
|
6
|
-
export {
|
|
7
|
-
src_default as default
|
|
8
|
-
};
|
package/dist/types/index.d.ts
DELETED