hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
182 stars 105 forks source link

[FEAT] Implement Endpoint to RETRIEVE About Page Content: settable from admin #265

Closed thenoblet closed 2 weeks ago

thenoblet commented 1 month ago

Description

Implement an endpoint to retrieve the content of the About page, allowing administrators to view the current information efficiently.


Purpose


Acceptance Criteria

Retrieve About Page Content


Requirements

Retrieve About Page Content


Expected Outcome


Checklist

  1. Retrieve About Page Content

    • [ ] Implement GET /api/v1/content/about endpoint.
    • [ ] Secure endpoint with authentication for administrators.
    • [ ] Document endpoint, including request and response formats.

Testing

Documentation:


Endpoint

Retrieve About Page Content

Description: Retrieve the current content of the About page.
Endpoint: GET /api/v1/content/about
Authentication: Required
Authorization: Administrators only
Response (Success):

{
    "title": "More Than Just A BoilerPlate",
    "introduction": "Welcome to Hng Boilerplate, where passion meets innovation.",
    "custom_sections": {
      "stats": {
        "years_in_business": 10,
        "customers": 75000,
        "monthly_blog_readers": 100000,
        "social_followers": 1200000
      },
      "services": {
        "title": "Trained to Give You The Best",
        "description": "Since our founding, Hng Boilerplate has been dedicated to constantly evolving to stay ahead of the curve."
      }
    },
  "status_code": 200,
  "message": "Retrieved About Page content successfully"
}

Response (Error: Server Issue):

{
  "message": "Failed to retrieve About page content.",
  "status_code": 500
}

Response (Error: Unauthenticated):

{
  "message": "Invalid authentication credentials",
  "status_code": 401
}

Response (Error: Authenticated but Unauthorised):

{
  "message": "You do not have the necessary permissions to access this resource",
  "status_code": 403
}

Additional Notes:

highb33kay commented 1 month ago

Please update this to follow the convention

{ "title": "More Than Just A BoilerPlate", "introduction": "Welcome to Hng Boilerplate, where passion meets innovation.", "custom_sections": { "stats": { "years_in_business": 10, "customers": 75000, "monthly_blog_readers": 100000, "social_followers": 1200000 }, "services": { "title": "Trained to Give You The Best", "description": "Since our founding, Hng Boilerplate has been dedicated to constantly evolving to stay ahead of the curve." } }, "status_code": 200 }****

Retiurn Response should be

data: status_code message

Popsicool commented 1 month ago

Update this, show the error response when an unauthenticated user or authenticated but unauthorized (non administrator) users use this endpoint. Also update the response using the convention stated above by @highb33kay

markessien commented 1 month ago

it would be better to use a generic content endpoint - e.g /content/about, where about is a category. I think all these types of pages should be consolidated into a single such endpoint group

thenoblet commented 1 month ago

@highb33kay, @Popsicool and @markessien, all suggestions and changes has been made, Mentors.

Please review again. Hopefully, it is exactly what you expect.