27 lines
766 B
Python
27 lines
766 B
Python
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from schemas.book import BookSchema
|
|
from helpers.book_helpers import get_all_books
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/books", response_model=List[BookSchema], status_code=status.HTTP_200_OK)
|
|
def get_all_books_endpoint(
|
|
skip: int = 0,
|
|
limit: int = 100,
|
|
db: Session = Depends(get_db)
|
|
):
|
|
"""
|
|
Retrieve all books from the database with pagination.
|
|
|
|
Parameters:
|
|
- skip: Number of records to skip (for pagination)
|
|
- limit: Maximum number of records to return (for pagination)
|
|
|
|
Returns:
|
|
- List of books
|
|
"""
|
|
books = get_all_books(db=db, skip=skip, limit=limit)
|
|
return books |