mirror of https://github.com/immich-app/immich.git
refactor: sdk init (#9563)
parent
975f2351ec
commit
136bb69bd0
@ -1,2 +1,25 @@
|
|||||||
|
import { defaults } from './fetch-client.js';
|
||||||
|
|
||||||
export * from './fetch-client.js';
|
export * from './fetch-client.js';
|
||||||
export * from './fetch-errors.js';
|
export * from './fetch-errors.js';
|
||||||
|
|
||||||
|
export interface InitOptions {
|
||||||
|
baseUrl: string;
|
||||||
|
apiKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const init = ({ baseUrl, apiKey }: InitOptions) => {
|
||||||
|
setBaseUrl(baseUrl);
|
||||||
|
setApiKey(apiKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getBaseUrl = () => defaults.baseUrl;
|
||||||
|
|
||||||
|
export const setBaseUrl = (baseUrl: string) => {
|
||||||
|
defaults.baseUrl = baseUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setApiKey = (apiKey: string) => {
|
||||||
|
defaults.headers = defaults.headers || {};
|
||||||
|
defaults.headers['x-api-key'] = apiKey;
|
||||||
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue