31 lines
1003 B
Python
31 lines
1003 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
|
|
def _split_csv(value: str) -> list[str]:
|
|
return [item.strip() for item in value.split(",") if item.strip()]
|
|
|
|
|
|
class Settings:
|
|
def __init__(self) -> None:
|
|
self.pb_url = os.getenv("PB_URL", "http://127.0.0.1:8090").rstrip("/")
|
|
self.pb_admin_email = os.getenv("PB_ADMIN_EMAIL", "admin@nomadcna.local")
|
|
self.pb_admin_password = os.getenv("PB_ADMIN_PASSWORD", "NomadCNA123456")
|
|
self.cookie_name = os.getenv("API_COOKIE_NAME", "pb_session")
|
|
self.frontend_origins = _split_csv(
|
|
os.getenv(
|
|
"FRONTEND_ORIGINS",
|
|
"http://localhost:3001,http://127.0.0.1:3001",
|
|
)
|
|
)
|
|
self.upload_dir = Path(os.getenv("UPLOAD_DIR", "backend/uploads"))
|
|
self.dev_auto_pay = os.getenv("DEV_AUTO_PAY", "true").lower() == "true"
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_settings() -> Settings:
|
|
return Settings()
|