hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
180 stars 105 forks source link

[FEAT] Implement Blog Search and Filtering API #25

Closed Ibukun-AL closed 1 month ago

Ibukun-AL commented 2 months ago

Implement Blog Search and Filtering API

Description

Creating an API that allows visitors to search and filter through blog content on the site without authentication, providing quick access to relevant articles and information.

Acceptance Criteria

Purpose

To enable users to search and filter blog posts based on various criteria such as author, title, content, tags, and creation date, while implementing robust security measures to protect data and prevent abuse.

Requirements

Expected Outcome

The backend should provide a reliable API endpoint that allows users to search and filter blog content securely and efficiently. It should handle requests based on specified criteria, including content, creation date (createdDate), and tags, while adhering to high-security standards. Additionally, the API should support pagination to ensure manageable response sizes.

Endpoints

Fetch Blogs:

Request Parameters:

Successful Response:


 {
  "currentPage": Int,
  "totalPages": Int,
  "totalResults": Int,
  "blogs": [
    {
      "id": "String",
      "title": "String",
      "content": "String",
      "author": "String",
      "createdDate": "String",
      "tags": ["String"]
    }
  ],
  "meta":{
    "hasNext": true,
    "total": 100,
    "nextPage": 2,
    "prevPage": null
  }
}

Error Response

{
  "message": "String",
  "error": "String",
  "statusCode": Int
}

Tasks

Testing

markessien commented 2 months ago

Remove the rate limiting feature, as its overkill. There is no need to specify something that is a given like "https protocol". I do not see how search is encrypted in the db.

Search in general should be done via a single typesense service.

Ibukun-AL commented 2 months ago

I've updated the issue description based on recent feedback and project requirements. Key changes include:

  1. Removed the rate limiting requirement as it was deemed unnecessary for this implementation.

  2. Eliminated the explicit mention of HTTPS protocol, as it's considered a standard practice.

  3. Removed references to encrypting search data in the database. This isn't typically done for search functionality as it would hinder performance and isn't necessary for public blog content.

  4. Added a requirement to integrate with Typesense service for efficient search functionality. This replaces the previous generic search implementation.

NdubuisiJr commented 2 months ago

@darionnuel this endpoint should be paginated

darionnuel commented 2 months ago

I have updated the endpoint to include pagination as requested. The endpoint now accepts page and pageSize parameters to give out a paginated response. I also edited the successful response, requirements and acceptance criteria, and tasks and testing sections to account for the new pagination logic.

Ace2489 commented 2 months ago

Here.

darionnuel commented 2 months ago

Team Members

@Ibukun-AL Spring Boot @Dricy FastAPI @Ace2489 .NET @darionnuel Nestjs

Dricy commented 2 months ago

here

NdubuisiJr commented 2 months ago

@darionnuel the response should contain the following pagination meta data.

{
   ...
   meta: {
     has_next: boolean,
     total: number,
     next_page: number | null,
     prev_page: number | null
  }
}
darionnuel commented 2 months ago

I cannot edit the issue any longer. It seems that I have been removed as a maintainer from the repo even though I am the team lead for my team.

Ibukun-AL commented 2 months ago

Updated the GitHub issue to reflect the new response structure

Popsicool commented 2 months ago

@darionnuel the response ought to be an object of objects, not an array of object. Remove the [] around the object you are returning

Ibukun-AL commented 2 months ago

Updated the response structure