hngprojects / hng_boilerplate_expressjs

75 stars 84 forks source link

[FEAT]: API Endpoint for Updating Product #121

Open Blard-omu opened 3 months ago

Blard-omu commented 3 months ago

Description

Implement an API endpoint for updating product information. This endpoint allows authenticated users to update product details such as name, description, price, and category.

Endpoint Features

Acceptance Criteria

Request Example

PUT /api/v1/products/:product_id
Content-Type: application/json

{
    "product_id": "123",
    "name": "New Product Name",
    "description": "Updated description",
    "price": 19.99,
    "category": "New Category"
  }

Response Example

{
  "status": "success",
  "status_code": 200,
  "message": "Product updated successfully.",
status: "success",
message: "Product updated successfully",
data: {
  "product_id": "123",
  "name": "New Product Name",
  "description": "Updated description",
  "price": 19.99,
  "stock": 50
}
}

Data Validation:

Input Validation

{
  "status": "Error",
  "status_code": 422,
  "message": "Valid product ID, name, description, price, and stock must be provided."
}

Output Validation

{
  "status": "Fail",
  "status_code": 500,
  "message": "Failed to update product. Please try again later."
}

Authentication And Authorization

Authentication

Authorization

Error Handling

Error Responses

{
  "status": "Fail",
  "status_code": 500,
  "message": "Failed to update product. Please try again later."
}

Edge Cases

Performance And Security

Performance Considerations

Security Concerns

Documentation

API Documentation

Technical Notes

Testing Requirements

Unit Tests

Integration Tests

Dependencies And Impact

Dependencies

Impact Analysis

AdeGneus commented 3 months ago

Your formatting is wrong. Why are you using snake case for the headings?

Blard-omu commented 3 months ago

Reviewed and updated

Blard-omu commented 3 months ago

Please mentor kindly check through again. I've made the necessary change. Thank you