hngprojects / hng_boilerplate_expressjs

75 stars 85 forks source link

[FEAT]: Implement an endpoint to get all comment on a blog post #224

Open dhamolahedonist opened 3 months ago

dhamolahedonist commented 3 months ago

Description:

Implement an endpoint to retrieve all comments on a specific blog post. This feature should ensure that users can fetch all comments associated with a particular blog post.

Acceptance Criteria:

API Endpoint Implementation:

Request Example:

GET /api/v1/blogs/123/comments Authorization: Bearer

Successful Response Example:

{
  "message": "Comments retrieved successfully",
  "status": 200,
  "comments": [
    {
      "id": 1,
      "author": "Jane Doe",
      "text": "Great post!",
      "timestamp": "2024-07-24T10:00:00Z"
    },
    {
      "id": 2,
      "author": "John Smith",
      "text": "Very informative.",
      "timestamp": "2024-07-24T11:00:00Z"
    }
  ]
}

Error Response Example:

{
  "message": "Unauthorized",
  "status": 401
}

or

{
  "message": "Blog post not found",
  "status": 404
}

or

{
  "message": "Internal server error",
  "status": 500
}

Purpose:

Enable users to retrieve all comments on a specific blog post, providing a way to view discussions and feedback associated with the post.

Requirements:

Status Codes:

200: Comments retrieved successfully,
401: Unauthorized access due to invalid token,
404: Blog post not found,
500: Internal server error,

Testing:

PreciousIfeaka commented 3 months ago

The request params should be in kebab case and the acceptance criteria should be checklists