Add POST endpoint for food
This commit is contained in:
parent
839d64fb2c
commit
0e747fdc97
19
endpoints/food.post.py
Normal file
19
endpoints/food.post.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user