@zairakai/js-http-client 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/index.cjs +6 -2
- package/dist/index.js +6 -2
- package/package.json +4 -1
- package/src/client.ts +7 -2
package/dist/index.cjs
CHANGED
|
@@ -151,12 +151,16 @@ var DEFAULT_CONFIG = {
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
var createHttpClient = (options = {}) => {
|
|
154
|
-
const config = {
|
|
154
|
+
const config = {
|
|
155
|
+
...DEFAULT_CONFIG,
|
|
156
|
+
...options,
|
|
157
|
+
headers: { ...DEFAULT_CONFIG.headers, ...options.headers ?? {} }
|
|
158
|
+
};
|
|
155
159
|
const client = import_axios2.default.create({
|
|
156
160
|
baseURL: config.baseURL,
|
|
157
161
|
timeout: config.timeout,
|
|
158
162
|
withCredentials: config.withCredentials,
|
|
159
|
-
headers:
|
|
163
|
+
headers: config.headers
|
|
160
164
|
});
|
|
161
165
|
const tracker = false !== config.trackRequests ? createRequestTracker() : null;
|
|
162
166
|
if (tracker) {
|
package/dist/index.js
CHANGED
|
@@ -47,12 +47,16 @@ var DEFAULT_CONFIG = {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
var createHttpClient = (options = {}) => {
|
|
50
|
-
const config = {
|
|
50
|
+
const config = {
|
|
51
|
+
...DEFAULT_CONFIG,
|
|
52
|
+
...options,
|
|
53
|
+
headers: { ...DEFAULT_CONFIG.headers, ...options.headers ?? {} }
|
|
54
|
+
};
|
|
51
55
|
const client = axios.create({
|
|
52
56
|
baseURL: config.baseURL,
|
|
53
57
|
timeout: config.timeout,
|
|
54
58
|
withCredentials: config.withCredentials,
|
|
55
|
-
headers:
|
|
59
|
+
headers: config.headers
|
|
56
60
|
});
|
|
57
61
|
const tracker = false !== config.trackRequests ? createRequestTracker() : null;
|
|
58
62
|
if (tracker) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zairakai/js-http-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Configurable HTTP client built on axios with request tracking, Laravel CSRF support, and interceptor management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"http",
|
|
@@ -100,5 +100,8 @@
|
|
|
100
100
|
},
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"overrides": {
|
|
105
|
+
"esbuild": "^0.28.1"
|
|
103
106
|
}
|
|
104
107
|
}
|
package/src/client.ts
CHANGED
|
@@ -90,14 +90,19 @@ const DEFAULT_CONFIG: Required<Pick<HttpClientOptions, 'baseURL' | 'timeout' | '
|
|
|
90
90
|
* @returns Configured axios instance with tracker
|
|
91
91
|
*/
|
|
92
92
|
export const createHttpClient = (options: HttpClientOptions = {}): HttpClient => {
|
|
93
|
-
|
|
93
|
+
// Deep-merge headers so DEFAULT_CONFIG.headers are never lost when options.headers is provided.
|
|
94
|
+
const config = {
|
|
95
|
+
...DEFAULT_CONFIG,
|
|
96
|
+
...options,
|
|
97
|
+
headers: { ...DEFAULT_CONFIG.headers, ...(options.headers ?? {}) },
|
|
98
|
+
}
|
|
94
99
|
|
|
95
100
|
// Create axios instance
|
|
96
101
|
const client = axios.create({
|
|
97
102
|
baseURL: config.baseURL,
|
|
98
103
|
timeout: config.timeout,
|
|
99
104
|
withCredentials: config.withCredentials,
|
|
100
|
-
headers:
|
|
105
|
+
headers: config.headers,
|
|
101
106
|
})
|
|
102
107
|
|
|
103
108
|
// Create request tracker if enabled
|