- Fix API routing: redirect_slashes=False + strip trailing slashes from route paths - Fix StaticFiles catch-all intercepting /api/* before FastAPI redirect - Add [tool.hatch.build.targets.wheel] to pyproject.toml for Docker builds - Install docker-compose plugin (v2.34.0) as CLI plugin - Create Dockerfile (python:3.11-alpine, CMD python -m lightsync) - Create docker-compose.prod.yml (Traefik + Authelia, edge network) - Deploy lightsync container to lightsync.groll.cloud - Add LightSync entry to start/projects.json - Update frontend app.js to use /api/devices (no trailing slash)
35 lines
983 B
Python
35 lines
983 B
Python
from fastapi import APIRouter, HTTPException
|
|
from lightsync.models.show import ShowModel
|
|
import lightsync.main as state # access show_store via module-level ref
|
|
|
|
router = APIRouter(tags=["shows"])
|
|
|
|
|
|
@router.get("")
|
|
async def list_shows():
|
|
"""Return summary list of all shows."""
|
|
summaries = []
|
|
for show_id in state.show_store.list_ids():
|
|
show = await state.show_store.load(show_id)
|
|
if show is not None:
|
|
summaries.append({
|
|
"id": str(show.id),
|
|
"name": show.name,
|
|
"created_at": show.created_at.isoformat(),
|
|
})
|
|
return summaries
|
|
|
|
|
|
@router.post("", status_code=201)
|
|
async def create_show(show: ShowModel) -> ShowModel:
|
|
await state.show_store.save(show)
|
|
return show
|
|
|
|
|
|
@router.get("/{show_id}")
|
|
async def get_show(show_id: str) -> ShowModel:
|
|
show = await state.show_store.load(show_id)
|
|
if show is None:
|
|
raise HTTPException(404, "Show not found")
|
|
return show
|