@hyper-fetch/core 3.0.0 → 3.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "private": false,
5
5
  "description": "Cache, Queue and Persist your requests no matter if you are online or offline!",
6
6
  "author": "Maciej Pyrc <m.pyrc@interia.pl>",
@@ -1,10 +1,15 @@
1
- import http from "http";
2
- import stream from "stream";
3
-
4
1
  import { getAdapterBindings, defaultTimeout, ResponseType, AdapterType, AdapterOptionsType } from "adapter";
5
2
  import { parseErrorResponse, parseResponse, getUploadSize, getStreamPayload } from "./adapter.utils";
6
3
 
7
4
  export const serverAdapter: AdapterType = async (request, requestId) => {
5
+ /**
6
+ * Prevent issues related to the missing Node.js polyfills
7
+ */
8
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
9
+ const http = require("http");
10
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
11
+ const stream = require("stream");
12
+
8
13
  const {
9
14
  fullUrl,
10
15
  headers,
@@ -22,15 +27,14 @@ export const serverAdapter: AdapterType = async (request, requestId) => {
22
27
  onError,
23
28
  onResponseEnd,
24
29
  } = await getAdapterBindings<AdapterOptionsType>(request, requestId);
25
-
26
30
  const { method } = request;
27
31
 
28
32
  return new Promise<ResponseType<unknown, unknown>>((resolve) => {
29
33
  const execute = async () => {
30
- const options: http.RequestOptions = {
34
+ const options = {
31
35
  path: fullUrl,
32
36
  method,
33
- headers: headers as http.RequestOptions["headers"],
37
+ headers,
34
38
  timeout: defaultTimeout,
35
39
  };
36
40