backend: improve error handling in API key validation to handle retrieval failures and rename .env for development
This commit is contained in:
parent
f28ea2bc56
commit
6e235d6fa7
@ -6,7 +6,7 @@ let envPath: string | undefined;
|
|||||||
if (process.env.MEET_CONFIG_DIR) {
|
if (process.env.MEET_CONFIG_DIR) {
|
||||||
envPath = process.env.MEET_CONFIG_DIR;
|
envPath = process.env.MEET_CONFIG_DIR;
|
||||||
} else if (process.env.NODE_ENV === 'development') {
|
} 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') {
|
} else if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'ci') {
|
||||||
envPath = '.env.test';
|
envPath = '.env.test';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -39,7 +39,14 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async validateApiKey(apiKey: string): Promise<boolean> {
|
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) {
|
if (storedApiKeys.length === 0 && !MEET_API_KEY) {
|
||||||
throw errorApiKeyNotConfigured();
|
throw errorApiKeyNotConfigured();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user