19 lines
570 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from schemas.fruit import FruitSchema
from helpers.fruit_helpers import get_all_fruits
router = APIRouter()
@router.get("/fruits", response_model=List[FruitSchema])
async def get_fruits(
skip: int = 0,
limit: int = 100,
sort_by: str = "created_at",
sort_desc: bool = True,
db: Session = Depends(get_db)
):
fruits = get_all_fruits(db, skip=skip, limit=limit, sort_by=sort_by, sort_desc=sort_desc)
return fruits