Newer
Older
bugtrail / server / app / config.py
from pathlib import Path

from pydantic_settings import BaseSettings, SettingsConfigDict


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

    # postgresql+asyncpg://ltt:ltt@postgres:5432/ltt
    database_url: str = "postgresql+asyncpg://ltt:ltt@localhost:5432/ltt"
    files_dir: Path = Path("./data/files")
    secret_key: str = "change-me"

    # share-page meta tags: where the built panel lives (index.html) and the
    # public origin used for absolute og:image/og:url links
    web_dist_dir: Path = Path("/srv/web")
    public_base_url: str = ""

    # sessions
    web_session_ttl_days: int = 30
    extension_session_ttl_days: int = 180

    # uploads
    max_upload_bytes: int = 25 * 1024 * 1024  # 25 MB
    max_input_value_length: int = 500

    # CORS: web dev server and browser extensions
    cors_origins: list[str] = [
        "http://localhost:5173",
        "http://127.0.0.1:5173",
        "chrome-extension://*",
        "moz-extension://*",
    ]


settings = Settings()