Files
tsumugu/backend/app/core/settings.py
T
LarsandCursor b328385561
Deploy Development / deploy (push) Failing after 39s
Lies Paperless-Dateien aus dem Ablageordner, wenn die Vorschau keine anzeigbare Datei liefert.
Eine unbekannte Dokumentnummer wird als solche gemeldet.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-17 07:12:35 +02:00

49 lines
1.4 KiB
Python

"""Process settings. Unknown environments refuse to start."""
from __future__ import annotations
from functools import lru_cache
from typing import Literal
from pydantic import field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(extra="ignore")
tsumugu_env: Literal["development", "production"]
db_host: str = "localhost"
db_port: int = 5432
db_name: str
db_user: str
db_password: str
db_runtime_user: str = "tsumugu_runtime"
app_url: str = "http://localhost:5173"
allowed_origins: str = "http://localhost:5173,http://localhost:3094"
media_root: str = "data/media"
paperless_media_root: str = ""
seed_demo: bool = False
session_ttl_hours: int = 336
upload_max_bytes: int = 20 * 1024 * 1024
@field_validator("allowed_origins")
@classmethod
def strip_origins(cls, value: str) -> str:
return value.strip()
@property
def origin_set(self) -> set[str]:
return {item.strip() for item in self.allowed_origins.split(",") if item.strip()}
def dsn(self, user: str | None = None) -> str:
return (
f"host={self.db_host} port={self.db_port} dbname={self.db_name} "
f"user={user or self.db_user} password={self.db_password} connect_timeout=5"
)
@lru_cache
def get_settings() -> Settings:
return Settings()