hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
182 stars 105 forks source link

[FEAT] - Generate Timeline Graph From Product Information - Backend #155

Closed Trojanhorse7 closed 2 weeks ago

Trojanhorse7 commented 1 month ago

Description

Develop an API endpoint to generate timeline graph from the product information

Acceptance Criteria

Request Parameters

{
  "status_code": 200,
  "timeline_graph": {
    "product_id": 1,
    "product_name": "Product Name",
    "description": "Product Description",
    "events": [
      {
        "date": "2024-01-01T00:00:00Z",
        "name": "Event Name",
        "description": "Event Description"
      },
      {
        "date": "2024-02-01T00:00:00Z",
        "name": "Another Event Name",
        "description": "Another Event Description"
      }
    ]
  }
}
{
  "status_code": 422,
  "error": [
    {
      "field": "product_name",
      "message": "Product Name is required"
    }
  ]
}
{
  "status_code": 403,
  "error": "Forbidden",
  "message": "User does not have the required permissions to generate a product-timeline."
}
{
  "status_code": 500,
  "error": "Internal Server Error",
  "message": "An unexpected error occurred. Please try again later."
}

Purpose

Provides a backend service that allows admins to generate product timeline from product information

Requirements

Expected Outcome

Task

Testing

Successful Timeline Graph Generation:

Ensure that the endpoint successfully generates a timeline graph for a product within the specified date range. Verify that the response includes the product ID, name, description, and events. Confirm that the status code is 200 OK.

Validation Errors:

Test scenarios with missing or invalid productId, startDate, or endDate in the request parameters. Verify that the endpoint returns a 400 Bad Request status code with appropriate error messages.

Unauthorized Access:

Test scenarios where the user is not an admin. Verify that the endpoint returns a 403 Forbidden status code.

Internal Server Error:

Simulate an internal server error to raise an exception. Verify that the endpoint returns a 500 Internal Server Error status code.

Database diagram

db img

markessien commented 1 month ago

We do not have a concept like "teams" in this app

markessien commented 1 month ago

You need to be clear on what exactly will be graphed.