Add POST endpoint for food

This commit is contained in:
Backend IM Bot 2025-03-28 15:56:50 +00:00
parent 839d64fb2c
commit 0e747fdc97

19
endpoints/food.post.py Normal file
View File

@ -0,0 +1,19 @@
# Entity: Food
from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.food import Food
from schemas.food import FoodSchema, FoodCreate
from helpers.food_helpers import create_foods
router = APIRouter()
@router.post("/food", status_code=201, response_model=List[FoodSchema])
async def add_foods(
foods: List[FoodCreate],
db: Session = Depends(get_db)
):
created_foods = create_foods(db, foods)
return created_foods