/** * =============================================================================== * ENVIRONMENT VARIABLE UTILITIES * =============================================================================== * * Type-safe utilities for reading environment variables with validation. * Extracted from http/config.ts for reuse across the codebase. * * Usage: * import { getEnv, getEnvNumber, getEnvBoolean } from '../core/config/env.js'; * * const port = getEnvNumber('PORT', 3000); * const debug = getEnvBoolean('DEBUG', false); * const apiKey = getEnv('API_KEY'); // throws if missing * * =============================================================================== */ /** * Get a required environment variable. * Throws if the variable is not set and no default is provided. * * @param key - Environment variable name * @param defaultValue - Optional default value * @returns The environment variable value * @throws Error if variable is missing and no default provided */ export declare function getEnv(key: string, defaultValue?: string): string; /** * Get an optional environment variable with a default value. * Never throws - always returns a value. * * @param key - Environment variable name * @param defaultValue - Default value if not set * @returns The environment variable value or default */ export declare function getEnvOptional(key: string, defaultValue: string): string; /** * Get an optional environment variable, returning undefined if not set. * * @param key - Environment variable name * @returns The environment variable value or undefined */ export declare function getEnvOrUndefined(key: string): string | undefined; /** * Get an environment variable as a number. * * @param key - Environment variable name * @param defaultValue - Default value if not set * @returns Parsed number value * @throws Error if value is not a valid number */ export declare function getEnvNumber(key: string, defaultValue: number): number; /** * Get an environment variable as a float. * * @param key - Environment variable name * @param defaultValue - Default value if not set * @returns Parsed float value * @throws Error if value is not a valid number */ export declare function getEnvFloat(key: string, defaultValue: number): number; /** * Get an environment variable as a boolean. * Accepts: 'true', '1', 'yes', 'on' (case-insensitive) as truthy. * * @param key - Environment variable name * @param defaultValue - Default value if not set * @returns Boolean value */ export declare function getEnvBoolean(key: string, defaultValue: boolean): boolean; /** * Get an environment variable as a comma-separated list. * * @param key - Environment variable name * @param defaultValue - Default array if not set * @param separator - Separator character (default: ',') * @returns Array of trimmed strings */ export declare function getEnvList(key: string, defaultValue?: string[], separator?: string): string[]; /** * Get an environment variable as a JSON object. * * @param key - Environment variable name * @param defaultValue - Default value if not set * @returns Parsed JSON object * @throws Error if value is not valid JSON */ export declare function getEnvJson(key: string, defaultValue: T): T; /** * Get an environment variable constrained to specific values (enum-like). * * @param key - Environment variable name * @param allowedValues - Array of allowed values * @param defaultValue - Default value if not set * @returns The environment variable value * @throws Error if value is not in allowed values */ export declare function getEnvEnum(key: string, allowedValues: readonly T[], defaultValue: T): T; /** * Result of environment validation. */ export interface EnvValidationResult { /** Whether all required variables are present */ valid: boolean; /** List of missing required variables */ missing: string[]; /** List of invalid variables (wrong format) */ invalid: Array<{ key: string; reason: string; }>; } /** * Validate that required environment variables are set. * * @param required - Array of required variable names * @returns Validation result */ export declare function validateRequiredEnv(required: string[]): EnvValidationResult; /** * Check if an environment variable is set (non-empty). * * @param key - Environment variable name * @returns true if the variable is set and non-empty */ export declare function hasEnv(key: string): boolean; /** * Get the current Node environment. * * @param defaultEnv - Default environment if NODE_ENV is not set * @returns Current environment name */ export declare function getNodeEnv(defaultEnv?: 'development' | 'production' | 'test'): 'development' | 'production' | 'test'; /** * Check if running in production mode. */ export declare function isProduction(): boolean; /** * Check if running in development mode. */ export declare function isDevelopment(): boolean; /** * Check if running in test mode. */ export declare function isTest(): boolean; //# sourceMappingURL=env.d.ts.map