import { z } from 'zod';

const envSchema = z.object({
  PORT: z.coerce.number().default(4016),
  HOST: z.string().default('0.0.0.0'),
  NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
  CORS_ORIGIN: z.string().optional(),
  SERVICE_NAME: z.string().default('bytelyst-notes-backend'),
  COSMOS_ENDPOINT: z.string().min(1, 'COSMOS_ENDPOINT is required').optional(),
  COSMOS_KEY: z.string().min(1, 'COSMOS_KEY is required').optional(),
  COSMOS_DATABASE: z.string().default('bytelyst'),
  JWT_SECRET: z.string().min(1, 'JWT_SECRET is required'),
  DB_PROVIDER: z.enum(['cosmos', 'memory']).default('cosmos'),
  PRODUCT_ID: z.string().default('bytelyst-notes'),
  PLATFORM_SERVICE_URL: z.string().default('http://localhost:4003'),
  EXTRACTION_SERVICE_URL: z.string().default('http://localhost:4005'),
  MCP_SERVER_URL: z.string().default('http://localhost:4007'),
});

export const config = envSchema.parse(process.env);
