@modern-js/create-request 2.10.0 → 2.11.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.
@@ -105,6 +105,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
105
105
  if (method.toLowerCase() === "get") {
106
106
  body = void 0;
107
107
  }
108
+ headers.accept = `application/json,*/*;q=0.8`;
108
109
  return fetcher(finalURL, {
109
110
  method,
110
111
  body,
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;
@@ -240,6 +240,7 @@ var createRequest = function(path, method, port) {
240
240
  if (method.toLowerCase() === "get") {
241
241
  body = void 0;
242
242
  }
243
+ headers.accept = "application/json,*/*;q=0.8";
243
244
  return [
244
245
  2,
245
246
  fetcher(finalURL, {
package/dist/esm/node.js CHANGED
@@ -131,6 +131,7 @@ var createRequest = function(path, method, port) {
131
131
  if (method.toLowerCase() === "get") {
132
132
  body = void 0;
133
133
  }
134
+ headers.accept = "application/json,*/*;q=0.8";
134
135
  return fetcher(url, {
135
136
  method: method,
136
137
  body: body,
@@ -72,6 +72,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
72
72
  if (method.toLowerCase() === "get") {
73
73
  body = void 0;
74
74
  }
75
+ headers.accept = `application/json,*/*;q=0.8`;
75
76
  return fetcher(finalURL, {
76
77
  method,
77
78
  body,
@@ -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;
@@ -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>;
@@ -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 Fetch = typeof fetch | typeof nodeFetch;
14
- export type Sender = ((...args: any[]) => Promise<any>) & {
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?: Fetch) => Sender;
18
- export type IOptions<F = Fetch> = {
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.10.0",
14
+ "version": "2.11.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.10.0"
63
+ "@modern-js/utils": "2.11.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.10.0",
74
- "@scripts/build": "2.10.0",
75
- "@scripts/jest-config": "2.10.0"
73
+ "@modern-js/types": "2.11.0",
74
+ "@scripts/jest-config": "2.11.0",
75
+ "@scripts/build": "2.11.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 };
@@ -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
- };
@@ -1,4 +0,0 @@
1
- import { RequestCreator, IOptions } from './types';
2
- declare const createRequest: RequestCreator;
3
- export declare const configure: (options: IOptions) => void;
4
- export default createRequest;