16 lines
513 B
Python
16 lines
513 B
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from typing import List, Optional
|
|
from sqlalchemy.orm import Session
|
|
from core.database import get_db
|
|
from schemas.fruit import FruitSchema
|
|
from helpers.fruit_helpers import get_all_fruits, get_fruit_by_id
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/fruits", status_code=status.HTTP_200_OK, response_model=List[FruitSchema])
|
|
def get_fruits(
|
|
order_by: Optional[str] = None,
|
|
db: Session = Depends(get_db)
|
|
):
|
|
return get_all_fruits(db, order_by)
|
|
|