from functools import lru_cache from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", extra="ignore") # Database database_url: str = "postgresql+psycopg2://pantry:pantry@localhost:5432/pantry" # Auth / JWT jwt_secret: str = "change-me-in-production" jwt_algorithm: str = "HS256" jwt_expire_minutes: int = 60 * 24 * 7 # 7 days # First admin, created on startup if no users exist admin_username: str = "admin" admin_password: str = "changeme" # Open Food Facts off_base_url: str = "https://world.openfoodfacts.org" off_timeout_seconds: float = 8.0 # Behaviour expiry_warning_days_default: int = 7 # CORS (comma separated); "*" allows all cors_origins: str = "*" @lru_cache def get_settings() -> Settings: return Settings()