@continuedev/fetch 1.0.4 → 1.0.6
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/fetch.js +11 -5
- package/dist/stream.js +1 -0
- package/package.json +1 -1
- package/src/fetch.ts +12 -5
- package/src/stream.ts +1 -0
package/dist/fetch.js
CHANGED
|
@@ -6,10 +6,10 @@ import { HttpProxyAgent } from "http-proxy-agent";
|
|
|
6
6
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
7
7
|
import fetch from "node-fetch";
|
|
8
8
|
const { http, https } = followRedirects.default;
|
|
9
|
-
export function fetchwithRequestOptions(url_, init, requestOptions) {
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
url =
|
|
9
|
+
export async function fetchwithRequestOptions(url_, init, requestOptions) {
|
|
10
|
+
const url = typeof url_ === "string" ? new URL(url_) : url_;
|
|
11
|
+
if (url.host === "localhost") {
|
|
12
|
+
url.host = "127.0.0.1";
|
|
13
13
|
}
|
|
14
14
|
const TIMEOUT = 7200; // 7200 seconds = 2 hours
|
|
15
15
|
let globalCerts = [];
|
|
@@ -80,11 +80,17 @@ export function fetchwithRequestOptions(url_, init, requestOptions) {
|
|
|
80
80
|
console.log("Unable to parse HTTP request body: ", e);
|
|
81
81
|
}
|
|
82
82
|
// fetch the request with the provided options
|
|
83
|
-
const resp = fetch(url, {
|
|
83
|
+
const resp = await fetch(url, {
|
|
84
84
|
...init,
|
|
85
85
|
body: updatedBody ?? init?.body,
|
|
86
86
|
headers: headers,
|
|
87
87
|
agent: agent,
|
|
88
88
|
});
|
|
89
|
+
if (!resp.ok) {
|
|
90
|
+
const requestId = resp.headers.get("x-request-id");
|
|
91
|
+
if (requestId) {
|
|
92
|
+
console.log(`Request ID: ${requestId}, Status: ${resp.status}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
89
95
|
return resp;
|
|
90
96
|
}
|
package/dist/stream.js
CHANGED
package/package.json
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -10,14 +10,14 @@ import fetch, { RequestInit, Response } from "node-fetch";
|
|
|
10
10
|
|
|
11
11
|
const { http, https } = (followRedirects as any).default;
|
|
12
12
|
|
|
13
|
-
export function fetchwithRequestOptions(
|
|
13
|
+
export async function fetchwithRequestOptions(
|
|
14
14
|
url_: URL | string,
|
|
15
15
|
init?: RequestInit,
|
|
16
16
|
requestOptions?: RequestOptions,
|
|
17
17
|
): Promise<Response> {
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
url =
|
|
18
|
+
const url = typeof url_ === "string" ? new URL(url_) : url_;
|
|
19
|
+
if (url.host === "localhost") {
|
|
20
|
+
url.host = "127.0.0.1";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const TIMEOUT = 7200; // 7200 seconds = 2 hours
|
|
@@ -107,12 +107,19 @@ export function fetchwithRequestOptions(
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// fetch the request with the provided options
|
|
110
|
-
const resp = fetch(url, {
|
|
110
|
+
const resp = await fetch(url, {
|
|
111
111
|
...init,
|
|
112
112
|
body: updatedBody ?? init?.body,
|
|
113
113
|
headers: headers,
|
|
114
114
|
agent: agent,
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
if (!resp.ok) {
|
|
118
|
+
const requestId = resp.headers.get("x-request-id");
|
|
119
|
+
if (requestId) {
|
|
120
|
+
console.log(`Request ID: ${requestId}, Status: ${resp.status}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
117
124
|
return resp;
|
|
118
125
|
}
|