@growi/sdk-typescript 1.0.0-RC.1 → 1.0.0-RC.2

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/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { DEFAULT_AXIOS_INSTANCE } from './utils/axios-instance.js';
1
+ export { AXIOS_DEFAULT } from './utils/axios-instance.js';
2
2
 
3
3
  export type * as Apiv1Types from './apiv1/index.js';
4
4
  export type * as Apiv3Types from './apiv3/index.js';
@@ -1,9 +1,27 @@
1
1
  import Axios, { type AxiosRequestConfig } from 'axios';
2
2
 
3
- export const DEFAULT_AXIOS_INSTANCE = Axios.create({
3
+ const DEFAULT_AXIOS_INSTANCE = Axios.create({
4
4
  baseURL: 'http://localhost', // set baseURL if you need
5
5
  });
6
6
 
7
+ export const AXIOS_DEFAULT = {
8
+ instance: DEFAULT_AXIOS_INSTANCE,
9
+ /**
10
+ * Set the base URL for the default Axios instance.
11
+ * @param baseURL The base URL to set for the Axios instance.
12
+ */
13
+ setBaseURL: (baseURL: string): void => {
14
+ DEFAULT_AXIOS_INSTANCE.defaults.baseURL = baseURL;
15
+ },
16
+ /**
17
+ * Set the Authorization header for the default Axios instance.
18
+ * @param token The authentication token to set in the Authorization header.
19
+ */
20
+ setAuthorizationHeader: (token: string): void => {
21
+ DEFAULT_AXIOS_INSTANCE.defaults.headers.common.Authorization = `Bearer ${token}`;
22
+ },
23
+ };
24
+
7
25
  export const customInstance = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
8
26
  const source = Axios.CancelToken.source();
9
27
  const promise = DEFAULT_AXIOS_INSTANCE({