media-rip/backend/app/routers/system.py
xpltd 9b62d50461 GSD: M002/S03 complete — Mobile + integration polish
- Admin panel: Settings tab with welcome message editor (runtime override)
- Backend: PUT /api/admin/settings endpoint for runtime config
- Backend: public config reads runtime overrides (settings_overrides on app.state)
- Removed unused ThemePicker.vue (replaced by DarkModeToggle in S01)
- Removed unused DownloadItem.vue (replaced by DownloadTable in S02)
- All 34 frontend + 179 backend tests passing
- M002 COMPLETE — all 3 slices done
2026-03-18 21:34:46 -05:00

35 lines
1.1 KiB
Python

"""System endpoints — public (non-sensitive) configuration for the frontend."""
from __future__ import annotations
import logging
from fastapi import APIRouter, Request
logger = logging.getLogger("mediarip.system")
router = APIRouter(tags=["system"])
@router.get("/config/public")
async def public_config(request: Request) -> dict:
"""Return the safe subset of application config for the frontend.
Explicitly constructs the response dict from known-safe fields.
Does NOT serialize the full AppConfig and strip fields — that pattern
is fragile when new sensitive fields are added later.
"""
config = request.app.state.config
# Runtime overrides (set via admin settings endpoint) take precedence
overrides = getattr(request.app.state, "settings_overrides", {})
return {
"session_mode": config.session.mode,
"default_theme": config.ui.default_theme,
"welcome_message": overrides.get(
"welcome_message", config.ui.welcome_message
),
"purge_enabled": config.purge.enabled,
"max_concurrent_downloads": config.downloads.max_concurrent,
}