@justins-home/http-client 1.0.1 → 1.0.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/.turbo/turbo-build.log +5 -6
- package/CHANGELOG.md +12 -0
- package/dist/index.js +21 -11
- package/dist/index.mjs +20 -11
- package/package.json +1 -1
- package/src/helpers/initClient.ts +11 -0
- package/src/index.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
WARN Issue while reading "/home/runner/work/justins-home-platform-ui/justins-home-platform-ui/.npmrc". Failed to replace env in config: ${NODE_AUTH_TOKEN}
|
|
2
1
|
|
|
3
|
-
> @justins-home/http-client@1.0.
|
|
2
|
+
> @justins-home/http-client@1.0.3 build /home/runner/work/justins-home-platform-ui/justins-home-platform-ui/packages/http-client
|
|
4
3
|
> tsup src/index.ts --format esm,cjs
|
|
5
4
|
|
|
6
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
[34mCLI[39m Target: es2023
|
|
10
9
|
[34mESM[39m Build start
|
|
11
10
|
[34mCJS[39m Build start
|
|
12
|
-
[32mCJS[39m [1mdist/index.js [22m[32m3.
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m1.
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m3.81 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 75ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.87 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 76ms
|
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
authClient: () => authClient,
|
|
34
34
|
createHttpClient: () => createHttpClient,
|
|
35
|
+
initApiToken: () => initApiToken,
|
|
35
36
|
publicClient: () => publicClient,
|
|
36
37
|
registerAuthInterceptor: () => registerAuthInterceptor,
|
|
37
38
|
registerErrorInterceptor: () => registerErrorInterceptor,
|
|
@@ -72,17 +73,6 @@ async function request(client, promise) {
|
|
|
72
73
|
return payload.data;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
// src/createHttpClient.ts
|
|
76
|
-
var import_axios3 = __toESM(require("axios"));
|
|
77
|
-
function createHttpClient(baseURL3) {
|
|
78
|
-
return import_axios3.default.create({
|
|
79
|
-
baseURL: baseURL3,
|
|
80
|
-
headers: {
|
|
81
|
-
"Content-Type": "application/json"
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
76
|
// src/interceptors/auth.interceptor.ts
|
|
87
77
|
function registerAuthInterceptor(getToken) {
|
|
88
78
|
authClient.interceptors.request.use((config) => {
|
|
@@ -95,6 +85,25 @@ function registerAuthInterceptor(getToken) {
|
|
|
95
85
|
});
|
|
96
86
|
}
|
|
97
87
|
|
|
88
|
+
// src/helpers/initClient.ts
|
|
89
|
+
var initialized = false;
|
|
90
|
+
function initApiToken(options) {
|
|
91
|
+
if (initialized) return;
|
|
92
|
+
registerAuthInterceptor(options.getToken);
|
|
93
|
+
initialized = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/createHttpClient.ts
|
|
97
|
+
var import_axios3 = __toESM(require("axios"));
|
|
98
|
+
function createHttpClient(baseURL3) {
|
|
99
|
+
return import_axios3.default.create({
|
|
100
|
+
baseURL: baseURL3,
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
// src/interceptors/error.interceptor.ts
|
|
99
108
|
function registerErrorInterceptor(client) {
|
|
100
109
|
client.interceptors.response.use(
|
|
@@ -111,6 +120,7 @@ function registerErrorInterceptor(client) {
|
|
|
111
120
|
0 && (module.exports = {
|
|
112
121
|
authClient,
|
|
113
122
|
createHttpClient,
|
|
123
|
+
initApiToken,
|
|
114
124
|
publicClient,
|
|
115
125
|
registerAuthInterceptor,
|
|
116
126
|
registerErrorInterceptor,
|
package/dist/index.mjs
CHANGED
|
@@ -31,17 +31,6 @@ async function request(client, promise) {
|
|
|
31
31
|
return payload.data;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// src/createHttpClient.ts
|
|
35
|
-
import axios3 from "axios";
|
|
36
|
-
function createHttpClient(baseURL3) {
|
|
37
|
-
return axios3.create({
|
|
38
|
-
baseURL: baseURL3,
|
|
39
|
-
headers: {
|
|
40
|
-
"Content-Type": "application/json"
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
34
|
// src/interceptors/auth.interceptor.ts
|
|
46
35
|
function registerAuthInterceptor(getToken) {
|
|
47
36
|
authClient.interceptors.request.use((config) => {
|
|
@@ -54,6 +43,25 @@ function registerAuthInterceptor(getToken) {
|
|
|
54
43
|
});
|
|
55
44
|
}
|
|
56
45
|
|
|
46
|
+
// src/helpers/initClient.ts
|
|
47
|
+
var initialized = false;
|
|
48
|
+
function initApiToken(options) {
|
|
49
|
+
if (initialized) return;
|
|
50
|
+
registerAuthInterceptor(options.getToken);
|
|
51
|
+
initialized = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/createHttpClient.ts
|
|
55
|
+
import axios3 from "axios";
|
|
56
|
+
function createHttpClient(baseURL3) {
|
|
57
|
+
return axios3.create({
|
|
58
|
+
baseURL: baseURL3,
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
// src/interceptors/error.interceptor.ts
|
|
58
66
|
function registerErrorInterceptor(client) {
|
|
59
67
|
client.interceptors.response.use(
|
|
@@ -69,6 +77,7 @@ function registerErrorInterceptor(client) {
|
|
|
69
77
|
export {
|
|
70
78
|
authClient,
|
|
71
79
|
createHttpClient,
|
|
80
|
+
initApiToken,
|
|
72
81
|
publicClient,
|
|
73
82
|
registerAuthInterceptor,
|
|
74
83
|
registerErrorInterceptor,
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerAuthInterceptor } from '../interceptors/auth.interceptor';
|
|
2
|
+
|
|
3
|
+
let initialized = false;
|
|
4
|
+
|
|
5
|
+
export function initApiToken(options: { getToken: () => string | null }) {
|
|
6
|
+
if (initialized) return;
|
|
7
|
+
|
|
8
|
+
registerAuthInterceptor(options.getToken);
|
|
9
|
+
|
|
10
|
+
initialized = true;
|
|
11
|
+
}
|