hngprojects / hng_boilerplate_expressjs

75 stars 85 forks source link

Fix: superadmin create faq #582

Open max-out-oluwadara opened 2 months ago

max-out-oluwadara commented 2 months ago

Fixes Issue/Linear Ticket

This could be an existing issue or a linear ticket

  • Github Issue Example: My PR Closes #{ISSUE}
  • Linear Ticket Example: Fixes ID-#{ISSUE}

Changes proposed

Added logic to check for duplicate FAQ entries in the database. Updated createFaq method in FAQService to ensure unique FAQ questions. Handled QueryFailedError for database operations.

The response body should be:

 {
  "status_code": 201,
  "message": "FAQ created successfully",
  "data": {
    "question": "What is the return policy?",
    "answer": "Our return policy allows returns within 30 days of purchase.",
    "category": "Policies",
    "id": "2dea5fe9-c635-4e6e-a059-ef3836b20661",
    "created_at": "2024-08-09T20:07:53.285Z",
    "updated_at": "2024-08-09T20:07:53.285Z"
  }
}

also the error message match

{
  "status_code": Error Code,
  "message": "Error Message",
  "data": {}
}

Check List (Check all the applicable boxes)

:rotating_light:Please review the [style guide for contributing](add link here) and [guidelines for contributing](add link here) to this repository.

Screenshots/ Videos