Update code in endpoints/api/v1/endpoint.get.py

This commit is contained in:
Backend IM Bot 2025-03-18 16:04:13 +00:00
parent 5156837cb5
commit f7208ac25f

View File

@ -0,0 +1,32 @@
from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
from typing import List, Dict
router = APIRouter()
@router.get("/books")
async def get_all_books():
"""Get all available books"""
books_db = {
"1": {
"id": "1",
"title": "Sample Book 1",
"author": "Author 1",
"published_year": 2023
},
"2": {
"id": "2",
"title": "Sample Book 2",
"author": "Author 2",
"published_year": 2022
}
}
return {
"message": "Books retrieved successfully",
"data": list(books_db.values()),
"metadata": {
"total_count": len(books_db),
"source": "demo_db"
}
}