mirror of
https://github.com/LukeHagar/immich.git
synced 2025-12-07 20:47:48 +00:00
fix: added assertNoApiKey function
This commit is contained in:
@@ -29,9 +29,7 @@ export const setApiKey = (apiKey: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const setHeader = (key: string, value: string) => {
|
export const setHeader = (key: string, value: string) => {
|
||||||
if (key.toLowerCase() === 'x-api-key') {
|
assertNoApiKey(key);
|
||||||
throw new Error('The API key header can only be set using setApiKey().');
|
|
||||||
}
|
|
||||||
defaults.headers = defaults.headers || {};
|
defaults.headers = defaults.headers || {};
|
||||||
defaults.headers[key] = value;
|
defaults.headers[key] = value;
|
||||||
};
|
};
|
||||||
@@ -39,13 +37,17 @@ export const setHeader = (key: string, value: string) => {
|
|||||||
export const setHeaders = (headers: Record<string, string>) => {
|
export const setHeaders = (headers: Record<string, string>) => {
|
||||||
defaults.headers = defaults.headers || {};
|
defaults.headers = defaults.headers || {};
|
||||||
for (const [key, value] of Object.entries(headers)) {
|
for (const [key, value] of Object.entries(headers)) {
|
||||||
if (key.toLowerCase() === 'x-api-key') {
|
assertNoApiKey(key);
|
||||||
throw new Error('The API key header can only be set using setApiKey().');
|
|
||||||
}
|
|
||||||
defaults.headers[key] = value;
|
defaults.headers[key] = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const assertNoApiKey = (headerKey: string) => {
|
||||||
|
if (headerKey.toLowerCase() === 'x-api-key') {
|
||||||
|
throw new Error('The API key header can only be set using setApiKey().');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getAssetOriginalPath = (id: string) => `/assets/${id}/original`;
|
export const getAssetOriginalPath = (id: string) => `/assets/${id}/original`;
|
||||||
|
|
||||||
export const getAssetThumbnailPath = (id: string) => `/assets/${id}/thumbnail`;
|
export const getAssetThumbnailPath = (id: string) => `/assets/${id}/thumbnail`;
|
||||||
|
|||||||
Reference in New Issue
Block a user