2025-03-28 17:58:48 +00:00

17 lines
536 B
Python

from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.fruit import Fruit
from schemas.fruit import FruitSchema, FruitCreate
from helpers.fruit_helpers import create_fruit
router = APIRouter()
@router.post("/fruits", status_code=201, response_model=FruitSchema)
async def create_fruit_entry(
fruit_data: FruitCreate,
db: Session = Depends(get_db)
):
new_fruit = create_fruit(db, fruit_data)
return new_fruit