diff --git a/endpoints/library.get.py b/endpoints/library.get.py new file mode 100644 index 0000000..5bec1f0 --- /dev/null +++ b/endpoints/library.get.py @@ -0,0 +1,27 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +import uuid + +router = APIRouter() + +@router.get("/library") +async def get_book_handler( + book_id: str, + db: Session = Depends(get_db), + token: str = Depends(oauth2_scheme) +): + """Get a book from the library""" + user = get_current_user_dummy(token) + book = db.query(Book).filter(Book.id == book_id).first() + + if not book: + raise HTTPException(status_code=404, detail="Book not found") + + return { + "message": "Book retrieved successfully", + "data": book, + "metadata": { + "user": user.username, + "source": "library_db" + } + } \ No newline at end of file