@leancodepl/axios-cqrs-client 8.3.2 → 8.3.3
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/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/package.json +3 -3
- package/src/lib/mkCqrsClient.d.ts +2 -1
package/index.cjs.js
CHANGED
|
@@ -27,7 +27,7 @@ function createError(error) {
|
|
|
27
27
|
error
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions }) {
|
|
30
|
+
function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader = "Authorization" }) {
|
|
31
31
|
const apiAxios = axios.create(_extends({
|
|
32
32
|
baseURL: cqrsEndpoint
|
|
33
33
|
}, axiosOptions));
|
|
@@ -35,7 +35,7 @@ function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions }) {
|
|
|
35
35
|
const token = await (tokenProvider == null ? void 0 : tokenProvider.getToken());
|
|
36
36
|
if (token) {
|
|
37
37
|
var _config_headers;
|
|
38
|
-
(_config_headers = config.headers) == null ? void 0 : _config_headers.set(
|
|
38
|
+
(_config_headers = config.headers) == null ? void 0 : _config_headers.set(tokenHeader, `Bearer ${token}`);
|
|
39
39
|
}
|
|
40
40
|
return config;
|
|
41
41
|
});
|
package/index.esm.js
CHANGED
|
@@ -25,7 +25,7 @@ function createError(error) {
|
|
|
25
25
|
error
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions }) {
|
|
28
|
+
function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader = "Authorization" }) {
|
|
29
29
|
const apiAxios = axios.create(_extends({
|
|
30
30
|
baseURL: cqrsEndpoint
|
|
31
31
|
}, axiosOptions));
|
|
@@ -33,7 +33,7 @@ function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions }) {
|
|
|
33
33
|
const token = await (tokenProvider == null ? void 0 : tokenProvider.getToken());
|
|
34
34
|
if (token) {
|
|
35
35
|
var _config_headers;
|
|
36
|
-
(_config_headers = config.headers) == null ? void 0 : _config_headers.set(
|
|
36
|
+
(_config_headers = config.headers) == null ? void 0 : _config_headers.set(tokenHeader, `Bearer ${token}`);
|
|
37
37
|
}
|
|
38
38
|
return config;
|
|
39
39
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/axios-cqrs-client",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/cqrs-client-base": "8.3.
|
|
7
|
-
"@leancodepl/validation": "8.3.
|
|
6
|
+
"@leancodepl/cqrs-client-base": "8.3.3",
|
|
7
|
+
"@leancodepl/validation": "8.3.3",
|
|
8
8
|
"axios": ">=1.6.0"
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
@@ -4,8 +4,9 @@ export type MkCqrsClientParameters = {
|
|
|
4
4
|
cqrsEndpoint: string;
|
|
5
5
|
tokenProvider?: TokenProvider;
|
|
6
6
|
axiosOptions?: CreateAxiosDefaults;
|
|
7
|
+
tokenHeader?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions }: MkCqrsClientParameters): {
|
|
9
|
+
export declare function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader, }: MkCqrsClientParameters): {
|
|
9
10
|
createQuery<TQuery, TResult>(type: string): (dto: TQuery) => Promise<ApiError | ApiSuccess<TResult>>;
|
|
10
11
|
createOperation<TOperation, TResult>(type: string): (dto: TOperation) => Promise<ApiError | ApiSuccess<TResult>>;
|
|
11
12
|
createCommand<TCommand, TErrorCodes extends {
|