fix: added assertNoApiKey function

This commit is contained in:
Luke Hagar
2025-08-24 18:22:47 -05:00
committed by GitHub
parent f7d069172c
commit fe9cadaca4

View File

@@ -29,9 +29,7 @@ export const setApiKey = (apiKey: string) => {
};
export const setHeader = (key: string, value: string) => {
if (key.toLowerCase() === 'x-api-key') {
throw new Error('The API key header can only be set using setApiKey().');
}
assertNoApiKey(key);
defaults.headers = defaults.headers || {};
defaults.headers[key] = value;
};
@@ -39,13 +37,17 @@ export const setHeader = (key: string, value: string) => {
export const setHeaders = (headers: Record<string, string>) => {
defaults.headers = defaults.headers || {};
for (const [key, value] of Object.entries(headers)) {
if (key.toLowerCase() === 'x-api-key') {
throw new Error('The API key header can only be set using setApiKey().');
}
assertNoApiKey(key);
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 getAssetThumbnailPath = (id: string) => `/assets/${id}/thumbnail`;