from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): app_name: str = "svg-service" app_env: str = "development" app_port: int = 9020 api_v1_prefix: str = "/api/v1" auth_header_name: str = "X-API-Key" admin_api_key: str = "admin-local-dev-key" viewer_api_key: str = "viewer-local-dev-key" postgres_host: str = "postgres" postgres_port: int = 5432 postgres_db: str = "svg_service" postgres_user: str = "svg_service" postgres_password: str = "svg_service_dev_password" svg_max_file_size_bytes: int = 10 * 1024 * 1024 svg_max_elements: int = 25000 svg_allow_internal_use_references_only: bool = True svg_forbid_foreign_object_v1: bool = True svg_forbid_style_v1: bool = False svg_forbid_image_v1: bool = True svg_display_enabled: bool = True svg_display_mode: str = "passthrough" svg_display_hide_small_text: bool = False svg_display_min_text_font_size: float = 8.0 svg_display_hide_technical_text: bool = False svg_display_remove_hidden_elements: bool = True svg_display_force_viewbox: bool = True svg_display_technical_text_patterns: str = "debug,tech,helper,tmp,service" storage_root_dir: str = "/data" publish_preview_retention_per_variant: int = 2 model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", case_sensitive=False, extra="ignore", ) @property def admin_keys(self) -> set[str]: return {item.strip() for item in self.admin_api_key.split(",") if item.strip()} @property def viewer_keys(self) -> set[str]: return {item.strip() for item in self.viewer_api_key.split(",") if item.strip()} @property def database_url(self) -> str: return ( f"postgresql+asyncpg://{self.postgres_user}:{self.postgres_password}" f"@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}" ) @property def storage_original_dir(self) -> str: return f"{self.storage_root_dir}/original" @property def storage_sanitized_dir(self) -> str: return f"{self.storage_root_dir}/sanitized" @property def storage_normalized_dir(self) -> str: return f"{self.storage_root_dir}/normalized" @property def storage_display_dir(self) -> str: return f"{self.storage_root_dir}/display" @property def storage_preview_dir(self) -> str: return f"{self.storage_root_dir}/preview" settings = Settings()