27 lines
706 B
Python
27 lines
706 B
Python
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"
|
|
}
|
|
} |