import path from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; import dotenv from 'dotenv'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const envCandidates = [ path.resolve(__dirname, '..', '.env'), path.resolve(__dirname, '..', '..', '.env'), path.resolve(process.cwd(), '.env'), ]; for (const candidate of envCandidates) { if (fs.existsSync(candidate)) { dotenv.config({ path: candidate, override: false }); break; } } class ConfigManager { static instance: ConfigManager | null = null; public PORT: number; public LOG_LEVEL: string; public TEMP_FOLDER: string; public AUTH_FOLDER: string; public API_URL: string; public API_TIMEOUT: number; public API_AUTH_TOKEN: string; public COMPANY_NAME: string; public FALLBACK_MESSAGE: string; public BOT_NUMERO_REAL: string; constructor() { this.PORT = Number(process.env.PORT || 3000); this.LOG_LEVEL = process.env.LOG_LEVEL || 'info'; this.TEMP_FOLDER = process.env.TEMP_FOLDER || './temp'; this.AUTH_FOLDER = process.env.AUTH_FOLDER || './auth_info_baileys'; this.API_URL = (process.env.API_URL || 'https://akra35567-akiragpu.hf.space/api').replace(/\/$/, ''); this.API_TIMEOUT = Number(process.env.API_TIMEOUT || 120000); this.API_AUTH_TOKEN = process.env.API_AUTH_TOKEN || ''; this.COMPANY_NAME = process.env.COMPANY_NAME || 'Akira'; this.BOT_NUMERO_REAL = (process.env.BOT_NUMERO_REAL || '').replace(/\D/g, ''); this.FALLBACK_MESSAGE = process.env.FALLBACK_MESSAGE || 'Sei la, o servidor caiu. Tenta de novo já já.'; ConfigManager.instance = this; } static getInstance(): ConfigManager { if (!ConfigManager.instance) { ConfigManager.instance = new ConfigManager(); } return ConfigManager.instance; } } export default ConfigManager;