From bd71599914f1f9c15fdad1dfbaff1bf919ca2028 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 22:19:44 +0000 Subject: [PATCH] Add POST endpoint for products --- endpoints/products.post.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 endpoints/products.post.py diff --git a/endpoints/products.post.py b/endpoints/products.post.py new file mode 100644 index 0000000..c52149b --- /dev/null +++ b/endpoints/products.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.product import Product +from schemas.product import ProductSchema, ProductCreate +from helpers.product_helpers import create_product + +router = APIRouter() + +@router.post("/products", status_code=201, response_model=ProductSchema) +async def add_product( + product: ProductCreate, + db: Session = Depends(get_db) +): + """Create a new product""" + new_product = create_product(db, product) + return new_product \ No newline at end of file