diff --git a/endpoints/api/v1/endpoint.get.py b/endpoints/api/v1/endpoint.get.py new file mode 100644 index 0000000..1dc2909 --- /dev/null +++ b/endpoints/api/v1/endpoint.get.py @@ -0,0 +1,39 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db + +router = APIRouter() + +@router.get("/books") +async def get_books( + limit: int = 10, + offset: int = 0 +): + """Get list of books""" + # Demo books data + books = [ + { + "id": "1", + "title": "Sample Book 1", + "author": "Author 1", + "year": 2023 + }, + { + "id": "2", + "title": "Sample Book 2", + "author": "Author 2", + "year": 2022 + } + ] + + paginated_books = books[offset:offset + limit] + + return { + "message": "Books retrieved successfully", + "data": paginated_books, + "metadata": { + "total_count": len(books), + "limit": limit, + "offset": offset, + "returned_count": len(paginated_books) + } + } \ No newline at end of file