fix(api): require user fmp api key

This commit is contained in:
root 2026-05-05 23:14:04 +00:00
parent 39456473cb
commit 0c0cc93f57

View File

@ -130,15 +130,6 @@ const normalizeNewsSymbolsQuery = (value: unknown): string => {
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> {
const profile = await getCurrentUserProfile(userId);
const profileApiKey = String(profile.FMP_API_KEY || '').trim();
@ -146,7 +137,7 @@ async function getUserFmpApiKey(userId: string): Promise<string> {
return profileApiKey;
}
return getConfiguredFmpApiKey();
throw new MissingServiceConfigError('User FMP API key is required for research and screener endpoints');
}
class MissingServiceConfigError extends Error {