Spaces:
Build error
Build error
| import { config } from 'dotenv'; | |
| import { z } from 'zod'; | |
| // Load variables from .env into process.env | |
| config(); | |
| const envSchema = z.object({ | |
| TELEGRAM_BOT_TOKEN: z.string().min(1, 'TELEGRAM_BOT_TOKEN is required'), | |
| TELEGRAM_USER_ID: z.string().min(1, 'TELEGRAM_USER_ID is required').transform(Number), | |
| WEBHOOK_URL: z.string().transform(s => s.trim()).optional(), | |
| API_BEARER_TOKEN: z.string().transform(s => s.trim()).optional(), | |
| // LLM provider selection | |
| LLM_PROVIDER: z.string().transform(s => s.trim()).default('gemini-web'), | |
| // Optional API keys (validated at runtime by each provider) | |
| GEMINI_API_KEY: z.string().optional().default(''), | |
| OPENAI_API_KEY: z.string().optional().default(''), | |
| OPENAI_BASE_URL: z.string().optional().default('https://api.openai.com/v1'), | |
| OLLAMA_BASE_URL: z.string().optional().default('http://localhost:11434'), | |
| // ntfy.sh push notifications | |
| NTFY_TOPIC: z.string().optional().default(''), | |
| NTFY_SERVER: z.string().optional().default('https://ntfy.sh'), | |
| // MongoDB Atlas | |
| MONGODB_URI: z.string().min(1, 'MONGODB_URI is required for the cloud migration').transform(s => s.trim()), | |
| }); | |
| const envParse = envSchema.safeParse(process.env); | |
| if (!envParse.success) { | |
| console.error('❌ Invalid or missing environment variables:'); | |
| console.error(envParse.error.format()); | |
| process.exit(1); | |
| } | |
| export const env = envParse.data; | |