"""Server configuration from environment variables.""" from pathlib import Path from typing import Any from pydantic_settings import BaseSettings class Settings(BaseSettings): """Application settings loaded from environment variables.""" data_dir: Path = Path("/data") database_url: str = "" secret_key: str = "change-me-in-production" def model_post_init(self, __context: Any) -> None: if self.secret_key == "change-me-in-production" and not self.debug: raise ValueError( "SECURITY: Cannot start with default secret_key in production. " "Set NOTIFY_BRIDGE_SECRET_KEY environment variable." ) access_token_expire_minutes: int = 60 refresh_token_expire_days: int = 30 host: str = "0.0.0.0" port: int = 8420 debug: bool = False anthropic_api_key: str = "" ai_model: str = "claude-sonnet-4-20250514" ai_max_tokens: int = 1024 telegram_webhook_secret: str = "" model_config = {"env_prefix": "NOTIFY_BRIDGE_"} @property def effective_database_url(self) -> str: if self.database_url: return self.database_url db_path = self.data_dir / "notify_bridge.db" return f"sqlite+aiosqlite:///{db_path}" settings = Settings()