backend: improve error handling in API key validation to handle retrieval failures and rename .env for development

This commit is contained in:
juancarmore 2025-06-19 17:17:42 +02:00
parent f28ea2bc56
commit 6e235d6fa7
3 changed files with 9 additions and 2 deletions

View File

@ -6,7 +6,7 @@ let envPath: string | undefined;
if (process.env.MEET_CONFIG_DIR) {
envPath = process.env.MEET_CONFIG_DIR;
} else if (process.env.NODE_ENV === 'development') {
envPath = '.env.development';
envPath = '.env.dev';
} else if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'ci') {
envPath = '.env.test';
} else {

View File

@ -39,7 +39,14 @@ export class AuthService {
}
async validateApiKey(apiKey: string): Promise<boolean> {
const storedApiKeys = await this.getApiKeys();
let storedApiKeys: { key: string; creationDate: number }[];
try {
storedApiKeys = await this.getApiKeys();
} catch (error) {
// If there is an error retrieving API keys, we assume they are not configured
storedApiKeys = [];
}
if (storedApiKeys.length === 0 && !MEET_API_KEY) {
throw errorApiKeyNotConfigured();