hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
181 stars 105 forks source link

[FIX] [BE: JAVA ANCHOR] Refactor Blog API Endpoint for Updating a Blog Entry #1159

Open olika-ashley opened 3 months ago

olika-ashley commented 3 months ago

Description

Refactor our current API endpoint for updating a blog entry by its ID to have the following route, request body, and response body.

Route

PUT /api/v1/blogs/{id}

Request Body

`

{

  "title": "string",

  "content": "string",

  "category": "Startup",

  "image_url": "string"

}
`

### Response Body
Status 200 ok
`
{

  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",

  "title": "string",

  "image_url": "string",

  "content": "string",

  "published_date": "2024-08-24T17:25:23.572Z",

  "updated_date": "2024-08-24T17:25:23.572Z",

  "author_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",

  "category": "Startup",

  "comments": [

    {

      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",

      "content": "string",

      "created_at": "2024-08-24T17:25:23.573Z"

    }

  ]

}

Status code 404

{

  "data": "string",

  "error": "string",

  "message": "string",

  "status_code": 0

}

Expected Outcome