hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
182 stars 105 forks source link

[FEAT] API Endpoint to create a Testimonial - Backend #206

Closed ugberaeseac closed 2 weeks ago

ugberaeseac commented 1 month ago

Description

Implement a protected API endpoint that allows authenticated users to create a new testimonial. Ensure the endpoint handles validation errors properly and returns the created testimonial along with appropriate status codes.

Acceptance Criteria

Authentication

Create Testimonial

Successful Response

Endpoint:

[POST] /api/v1/testimonials 

Requests

POST /api/v1/testimonials
Content-Type: application/json
Authorization: Bearer <access_token>

{
    “name”: “Charles Ugberaese”,
    “content”: “The service is fantastic, great experience, ”,
}

Successful Response

{
  "status": "success",
  "message": "Testimonial created successfully",
  "data": 
{
    “user_id”: “0b89cd08-57fc-40b0-aa17-ed6d95f43cfe”,
    “name”: “Charles Ugberaese”,
    “content”: “The service is fantastic, great experience, ”,
    “created_at”:  “2024–07-18”
}
}

Error Response

401 Unauthorized

{
  "status":  "Unauthorized",
  "message":  "Unauthorized. Please log in."
  “status_code”: 401
}

400 Bad Request

{
  "status":  "Bad Request",
  "message":  "Please check the submitted data"
  “status_code”: 400
}

500 Internal Server Error

{
  "status":  "Internal Server Error",
  "message":  "Internal Server Error. Please try again later."
  “status_code”: 500
}

Purpose

Allow authenticated users to submit and create new testimonials and ensure that the submitted data is stored accurately in the database.

Requirements

Expected Outcome

Testing:

Unit Tests:

AsciencioAlex commented 1 month ago

this is a duplicate to this #201

chionz commented 1 month ago

This is a duplicate of #201 Sir

ugberaeseac commented 1 month ago

Go through the github issue again and DELETE your comments

Do you not see that #201 is to GET all testimonials and #206 is to create a Testimonial by an authenticated user

abdielbytes commented 1 month ago

okay here