From 6143597a227d4f410b3cdc9cdbe7497c59d0c41b Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 07:58:22 +0000 Subject: [PATCH] Update code in endpoints/books.post.py --- endpoints/books.post.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/endpoints/books.post.py b/endpoints/books.post.py index e69de29..48dc229 100644 --- a/endpoints/books.post.py +++ b/endpoints/books.post.py @@ -0,0 +1,17 @@ +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +from core.database import get_db +from models.book import Book +from schemas.book import BookSchema, BookCreate +from helpers.book_helpers import create_book + +router = APIRouter() + +@router.post("/books", status_code=201, response_model=BookSchema) +async def add_book( + book: BookCreate, + db: Session = Depends(get_db) +): + """Add a new book""" + new_book = create_book(db=db, book=book) + return new_book \ No newline at end of file