hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
182 stars 105 forks source link

[FEAT] : Delete product API - Backend #77

Closed covenant123456 closed 2 weeks ago

covenant123456 commented 1 month ago

Description:

Develop a secure backend API endpoint that allows for the deletion of a product by its ID. This service will enable authenticated users to remove specific products from the database. The endpoint should handle scenarios where the product does not exist and return appropriate error messages.

Purpose:

Provide a reliable and secure backend service for deleting products, ensuring efficient management and cleanup of product data.

Requirements:

  1. Implement Endpoint:
    • Develop an endpoint to delete a product by its ID.
    • Endpoint should be accessible via a DELETE request.
  2. Ensure Endpoint Security:
    • Secure the endpoint to ensure only authenticated users can delete products.
    • Implement authentication checks.
  3. Handle Non-existent Products:
    • Implement error handling for cases where the requested product ID does not exist in the database.
    • Return a meaningful error message when a product is not found.

Acceptance Criteria:

Checklist:

Endpoint:

API Request: Delete Product

DELETE /api/v1/products/{productId}
Headers:
  Authorization: Bearer <token>

API Response: Success (200)

{
    "message": "Product deleted successfully."
}

API Response: Product Not Found (404)

{
    "error": "Product not found",
    "message": "The product with ID 999 does not exist."
}

API Response: Unauthorized (401)

{
    "error": "Unauthorized",
    "message": "You must be authenticated to delete a product."
}

Dependencies:

markessien commented 1 month ago

Split these into one ticket per operation

markessien commented 1 month ago

Also, this seems to be a duplicate

covenant123456 commented 1 month ago

Team members slack id: @Synth Go @Deola Deosun phyton @Covenant12 Laravel PHP @Meysdays Java @Naina Nodejs

NdubuisiJr commented 1 month ago

@covenant123456 Indicate the status code the endpoint will return and following the route versioning pattern.

covenant123456 commented 1 month ago

the status code has been included and the route is following the versioning pattern