All files / src/Infrastructure/Environments config.ts

100% Statements 6/6
72.22% Branches 13/18
100% Functions 0/0
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 673x 3x   3x                                                                       3x         3x                                         3x  
import { LoggerLevels, isLoggerLevel } from '@Infrastructure/Monitoring/Logger';
import dotenv from 'dotenv';
 
dotenv.config();
 
interface ServerConfig {
    port: number;
    nodeEnv: string;
}
 
interface AppConfig {
    name: string;
    version: string;
}
 
interface LoggerConfig {
    level: LoggerLevels;
}
 
interface PokemonClientConfig {
    baseUrl: string;
}
 
interface TranslatorClientConfig {
    baseUrl: string;
    apiKey: string;
}
 
/**
 * Configuration interface for the application
 */
interface Config {
    server: ServerConfig;
    app: AppConfig;
    logger: LoggerConfig;
    pokemonClient: PokemonClientConfig;
    translatorClient: TranslatorClientConfig;
}
 
const logLevel = process.env['LOGGER_LEVEL'] ?? 'info';
 
/**
 * Application configuration object
 */
const config: Config = {
    server: {
        port: Number(process.env['PORT'] ?? 3000),
        nodeEnv: process.env['NODE_ENV'] ?? 'development',
    },
    app: {
        name: process.env['APP_NAME'] ?? 'Pokedex',
        version: process.env['APP_VERSION'] ?? '1.0.0',
    },
    logger: {
        level: isLoggerLevel(logLevel) ? logLevel : 'info',
    },
    pokemonClient: {
        baseUrl: process.env['POKEMON_API_BASE_URL'] ?? '',
    },
    translatorClient: {
        baseUrl: process.env['TRANSLATOR_API_BASE_URL'] ?? '',
        apiKey: process.env['TRANSLATOR_API_KEY'] ?? '',
    }
};
 
export default config;