highlife-15d6hb/endpoints/playlist.get.py
2025-03-28 15:21:14 +00:00

23 lines
667 B
Python

# Entity: Meal
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.meal import Meal
from schemas.meal import MealSchema
from helpers.meal_helpers import get_all_meals, get_meals_by_category
router = APIRouter()
@router.get("/meals", status_code=200, response_model=List[MealSchema])
async def get_meals(
category: str = None,
db: Session = Depends(get_db)
):
"""Get all meals with optional category filter"""
if category:
meals = get_meals_by_category(db, category)
else:
meals = get_all_meals(db)
return meals