Files

29 lines
1.1 KiB
Python
Raw Permalink Normal View History

2026-09-06 00:05:10 -05:00
"""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)