from pathlib import Path

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    database_url: str = "postgresql://forma_n8:forma_n8@127.0.0.1:5432/forma_n8"
    site_base_url: str = "http://127.0.0.1:8090"
    site_name: str = "Forma N8"
    site_tagline: str = "Новости снаряжения"
    site_indexing_enabled: bool = False
    publish_api_token: str = ""
    upload_dir: Path = Path("/var/lib/forma-n8/uploads")
    page_size: int = 12

    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")

    @property
    def base_url(self) -> str:
        return self.site_base_url.rstrip("/")


settings = Settings()
