22 lines
680 B
Python
22 lines
680 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.database import fake_users_db
|
|
|
|
router = APIRouter()
|
|
|
|
fake_books_db = {
|
|
"1": {"id": "1", "title": "The Great Gatsby", "author": "F. Scott Fitzgerald"},
|
|
"2": {"id": "2", "title": "1984", "author": "George Orwell"},
|
|
"3": {"id": "3", "title": "To Kill a Mockingbird", "author": "Harper Lee"}
|
|
}
|
|
|
|
@router.get("/books")
|
|
async def get_books():
|
|
"""Get all books from the database"""
|
|
return {
|
|
"message": "Books retrieved successfully",
|
|
"data": list(fake_books_db.values()),
|
|
"metadata": {
|
|
"total_count": len(fake_books_db),
|
|
"source": "demo_db"
|
|
}
|
|
} |