Add GET /genres directory endpoint
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s

GET /movies and GET /series accept a genre filter (an Aurora genre id),
but nothing exposed what those ids actually are -- genres otherwise
only ever appear embedded in a movie/series response's own genres
list. This is the resolve-by-name-first-then-filter step the frontend
needs to build real genre browsing.

No filter, no sort_by -- always alphabetical by name, same pattern as
collections/companies (genres have no categorical field or popularity/
date to sort by). page_size defaults to 50 (max 200) rather than the
20/50 used elsewhere, since genres are a small, fixed reference set
(TMDb has ~19-20 total) a client typically wants in full for a filter
dropdown, not paginated like a catalog of millions of movies.

Also fixed two stale "behind Traefik" mentions in app/main.py's module
docstring while touching this file, left over from the earlier
cPanel/host-webserver deployment change.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-06 00:05:10 -05:00
co-authored by Claude Sonnet 5
parent 71388e254e
commit 340cadd99d
7 changed files with 179 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Genre endpoints (section 17: additive) -- a directory for the `genre`
filter GET /movies and GET /series already accept, which takes an Aurora
genre id with no prior way to discover what those ids are."""
from __future__ import annotations
from fastapi import APIRouter, Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.database import get_db
from app.core.security import enforce_rate_limit
from app.schemas.common import GenreListOut
from app.services import genre_service
router = APIRouter(prefix="/genres", tags=["genres"], dependencies=[Depends(enforce_rate_limit)])
@router.get("", response_model=GenreListOut)
async def list_genres(
page: int = Query(1, ge=1),
# Genres are a small, fixed reference set (TMDb has ~19-20 total) --
# default/max page_size sized so a client can fetch the whole
# directory in one call for a filter dropdown, unlike the huge
# catalogs GET /movies etc. paginate through.
page_size: int = Query(50, ge=1, le=200),
session: AsyncSession = Depends(get_db),
) -> GenreListOut:
return await genre_service.list_genres(session, page=page, page_size=page_size)