diff --git a/app/routes/pins.py b/app/routes/pins.py index b406694..94ba1b3 100644 --- a/app/routes/pins.py +++ b/app/routes/pins.py @@ -70,4 +70,19 @@ async def add_pin(pin: PinDTO, current_user: User = Depends(get_current_user)): ) async def list_pins(current_user: User = Depends(get_current_user)): pins = serializers.pins_serialize(pins_collection.find().to_list(), current_user.uid) - return pins \ No newline at end of file + return pins + +@pins_router.delete( + path="/{id}", + responses={401: {"model": HTTPError}, 404: {"model": HTTPError}, 422: {"model": HTTPError}} +) +async def delete_pin(id: str, current_user: User = Depends(get_current_user)): + try: + result = pins_collection.delete_one({"_id": ObjectId(id)}) + except bson.errors.InvalidId: + objectid_misformatted() + + if result.deleted_count == 0: + raise HTTPException(status_code=404, detail="Pin not found") + + return {"message": "Pin deleted"} \ No newline at end of file