@hyper-fetch/core 5.1.1 → 5.2.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/browser/index.cjs.js +6 -1
- package/dist/browser/index.cjs.js.map +2 -2
- package/dist/browser/index.esm.js +6 -1
- package/dist/browser/index.esm.js.map +2 -2
- package/dist/index.cjs.js +8 -3
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +8 -3
- package/dist/index.esm.js.map +2 -2
- package/package.json +1 -1
- package/src/adapter/adapter.bindings.ts +3 -1
- package/src/adapter/adapter.server.ts +3 -2
- package/src/client/client.ts +11 -0
package/dist/index.cjs.js
CHANGED
|
@@ -306,7 +306,6 @@ var adapter2 = (request, requestId) => __async(void 0, null, function* () {
|
|
|
306
306
|
const { method = "GET" /* get */, client } = request;
|
|
307
307
|
const httpClient = client.url.includes("https://") ? import_https.default : import_http.default;
|
|
308
308
|
const options = {
|
|
309
|
-
path: fullUrl,
|
|
310
309
|
method,
|
|
311
310
|
headers,
|
|
312
311
|
timeout: defaultTimeout
|
|
@@ -319,8 +318,9 @@ var adapter2 = (request, requestId) => __async(void 0, null, function* () {
|
|
|
319
318
|
if (payload) {
|
|
320
319
|
options.headers["Content-Length"] = Buffer.byteLength(JSON.stringify(payload));
|
|
321
320
|
}
|
|
321
|
+
const requestUrl = !fullUrl.startsWith("http") ? `http://${fullUrl}` : fullUrl;
|
|
322
322
|
return makeRequest((resolve) => {
|
|
323
|
-
const httpRequest = httpClient.request(options, (response) => {
|
|
323
|
+
const httpRequest = httpClient.request(requestUrl, options, (response) => {
|
|
324
324
|
response.setEncoding("utf8");
|
|
325
325
|
unmountListener = createAbortListener(0, xhrExtra, response.destroy, resolve);
|
|
326
326
|
let chunks = "";
|
|
@@ -1508,7 +1508,7 @@ var getAdapterBindings = (req, requestId, systemErrorStatus, systemErrorExtra) =
|
|
|
1508
1508
|
if (processingError) {
|
|
1509
1509
|
return onError(processingError, systemErrorStatus, systemErrorExtra, () => null);
|
|
1510
1510
|
}
|
|
1511
|
-
if (req.mock && req.isMockEnabled) {
|
|
1511
|
+
if (req.mock && req.isMockEnabled && req.client.isMockEnabled) {
|
|
1512
1512
|
return mocker(request, {
|
|
1513
1513
|
onError,
|
|
1514
1514
|
onResponseEnd,
|
|
@@ -2298,6 +2298,7 @@ var Client = class {
|
|
|
2298
2298
|
this.loggerManager = new LoggerManager(this);
|
|
2299
2299
|
this.defaultMethod = "GET" /* get */;
|
|
2300
2300
|
this.defaultExtra = xhrExtra;
|
|
2301
|
+
this.isMockEnabled = true;
|
|
2301
2302
|
this.effects = [];
|
|
2302
2303
|
this.abortKeyMapper = getSimpleKey;
|
|
2303
2304
|
this.cacheKeyMapper = getRequestKey;
|
|
@@ -2344,6 +2345,10 @@ var Client = class {
|
|
|
2344
2345
|
this.payloadMapper = payloadMapper;
|
|
2345
2346
|
return this;
|
|
2346
2347
|
};
|
|
2348
|
+
this.setEnableGlobalMocking = (isMockEnabled) => {
|
|
2349
|
+
this.isMockEnabled = isMockEnabled;
|
|
2350
|
+
return this;
|
|
2351
|
+
};
|
|
2347
2352
|
this.setEndpointMapper = (endpointMapper) => {
|
|
2348
2353
|
this.endpointMapper = endpointMapper;
|
|
2349
2354
|
return this;
|