fix(api): require user fmp api key
This commit is contained in:
parent
39456473cb
commit
0c0cc93f57
@ -130,15 +130,6 @@ const normalizeNewsSymbolsQuery = (value: unknown): string => {
|
|||||||
return symbols.join(',');
|
return symbols.join(',');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConfiguredFmpApiKey = (): string => {
|
|
||||||
const apiKey = config.FMP_API_KEY.trim();
|
|
||||||
if (!apiKey || apiKey.toLowerCase() === 'demo') {
|
|
||||||
throw new MissingServiceConfigError('FMP_API_KEY is required for research and screener endpoints');
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiKey;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function getUserFmpApiKey(userId: string): Promise<string> {
|
async function getUserFmpApiKey(userId: string): Promise<string> {
|
||||||
const profile = await getCurrentUserProfile(userId);
|
const profile = await getCurrentUserProfile(userId);
|
||||||
const profileApiKey = String(profile.FMP_API_KEY || '').trim();
|
const profileApiKey = String(profile.FMP_API_KEY || '').trim();
|
||||||
@ -146,7 +137,7 @@ async function getUserFmpApiKey(userId: string): Promise<string> {
|
|||||||
return profileApiKey;
|
return profileApiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getConfiguredFmpApiKey();
|
throw new MissingServiceConfigError('User FMP API key is required for research and screener endpoints');
|
||||||
}
|
}
|
||||||
|
|
||||||
class MissingServiceConfigError extends Error {
|
class MissingServiceConfigError extends Error {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user