@springbrand/http 0.1.0-alpha.4 → 0.1.0-alpha.5
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.
|
@@ -24,7 +24,7 @@ Create one client per trusted API origin. Inject getToken; do not copy Token sto
|
|
|
24
24
|
|
|
25
25
|
Pass params for query serialization and signal/timeoutMs for cancellation/deadlines. Null/undefined query values are omitted; use a string for literal null. Do not duplicate query encoding or timeout controllers in domain clients.
|
|
26
26
|
|
|
27
|
-
Use get/post/put/patch/delete for payloads, request for data plus status and headers. Explicitly choose json, text or blob for endpoints without the standard success envelope. FormData owns its boundary. Pass Query's signal through; do not wrap cancellation as network failure.
|
|
27
|
+
Use get/post/put/patch/delete for payloads, request for data plus status and headers. Explicitly choose json, text or blob for endpoints without the standard success envelope. FormData owns its boundary. The client sends no User-Agent of its own (Safari and Firefox would otherwise require every cross-origin API to allow it in CORS); set one explicitly only for a server-to-server call that needs it. Pass Query's signal through; do not wrap cancellation as network failure.
|
|
28
28
|
|
|
29
29
|
## Error handling
|
|
30
30
|
|
package/dist/client.js
CHANGED
|
@@ -57,6 +57,7 @@ function createHttpClient(config) {
|
|
|
57
57
|
if (options.body instanceof FormData) headers.delete("Content-Type");
|
|
58
58
|
if (timeout > 0) timer = setTimeout(() => controller.abort(sdkError("REQUEST_TIMEOUT", { status: 0, kind: "timeout" })), timeout);
|
|
59
59
|
const requestHeaders = new axios.AxiosHeaders(Object.fromEntries(headers));
|
|
60
|
+
if (!requestHeaders.has("User-Agent")) requestHeaders.set("User-Agent", false);
|
|
60
61
|
if (options.body instanceof FormData) requestHeaders.setContentType("multipart/form-data");
|
|
61
62
|
const response = await transport.request({
|
|
62
63
|
url: url.href,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springbrand/http",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -58,13 +58,6 @@
|
|
|
58
58
|
},
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
|
-
"scripts": {
|
|
62
|
-
"build": "vite build && tsc -p tsconfig.build.json",
|
|
63
|
-
"watch": "vite build --watch",
|
|
64
|
-
"typecheck": "tsc --noEmit",
|
|
65
|
-
"lint": "eslint src tests --ext ts --max-warnings 0",
|
|
66
|
-
"test": "vitest run"
|
|
67
|
-
},
|
|
68
61
|
"dependencies": {
|
|
69
62
|
"axios": "1.20.0",
|
|
70
63
|
"content-disposition": "2.0.1"
|
|
@@ -95,5 +88,12 @@
|
|
|
95
88
|
"vite": "^5.4.19",
|
|
96
89
|
"vitest": "3.2.6",
|
|
97
90
|
"zod": "4.6.5"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
94
|
+
"watch": "vite build --watch",
|
|
95
|
+
"typecheck": "tsc --noEmit",
|
|
96
|
+
"lint": "eslint src tests --ext ts --max-warnings 0",
|
|
97
|
+
"test": "vitest run"
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
}
|