Add GET endpoint for food
This commit is contained in:
parent
daec2c5d58
commit
f5da81fdc5
19
endpoints/food.get.py
Normal file
19
endpoints/food.get.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Entity: Food
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, 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
|
||||
from helpers.food_helpers import get_all_foods
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/food", status_code=200, response_model=List[FoodSchema])
|
||||
async def get_food_list(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get all food items in the menu"""
|
||||
foods = get_all_foods(db)
|
||||
return foods
|
Loading…
x
Reference in New Issue
Block a user