"""Application configuration using Pydantic Settings.""" from pydantic_settings import BaseSettings from typing import Optional class Settings(BaseSettings): """Application settings loaded from environment variables.""" # App Info APP_NAME: str = "Service App" APP_VERSION: str = "1.0.0" API_V1_PREFIX: str = "/api/v1" # Database DATABASE_URL: str = "sqlite:////config/config.db" # Security SECRET_KEY: str ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440 # 24 hours # CORS ALLOWED_HOSTS: list[str] = [] CORS_ORIGINS: list[str] = [ "http://localhost:3000", "http://localhost:5173", # Vite dev server "http://127.0.0.1:3000", "http://127.0.0.1:5173", ] @property def all_cors_origins(self) -> list[str]: """Combine default CORS origins with allowed hosts.""" return self.CORS_ORIGINS + self.ALLOWED_HOSTS # Logging LOG_LEVEL: str = "info" DEBUG: bool = False class Config: env_file = ".env" case_sensitive = True extra = "ignore" # Ignore extra fields from .env (like VITE_* for frontend) # Global settings instance settings = Settings()