hngprojects / hng_boilerplate_golang_web

Apache License 2.0
77 stars 50 forks source link

[FEAT] HELP CENTER - SEARCH ARTICLE(s). #4

Closed salissadiq closed 1 month ago

salissadiq commented 1 month ago

Description

This page serves as the central hub for our help center, providing users with access to a wealth of informative articles. With its intuitive search functionality, users can easily find the articles they need to address their questions or concerns. Additionally, the help center page implements rate limiting on its search endpoints.

Acceptance Criteria

Purpose

Users can search for articles by titles / topics.

Requirements

Endpoints

[GET] /api/v1/topics/search?title={title}

Description

Successful Response

Status code: 200

{
  "success": true,
  "message": "string",
  "status_code": 200
  "topics": [
    {
      "article_id": "int",
      "title": "string",
      "content": "string"
    }
    ...
  ]
}

Error Response

Status code: 404

No article matches the title search param.

{
  "success": false,
  "message": "string",
  "status_code": 404
}

Status code: 429

Too many requests, Rate limit reached.

{
  "success": false,
  "message": "string",
  "status_code": 429
}

Status code: 500

Internal Server Error

{
  "success": false,
  "message": "string",
  "status_code": 500
}

Database Schema

Table name: articles_table

- article_id:
  - constraints: string(uuid), unique, primary-key, not null
- title:
  - constraints: string, unique, not null, text
- content:
  - constraints: string, not null, text
- createdAt:
  - constraints: datetime
- updatedAt:
  - constraints: datetime

Database diagram

Database image

Testing

  1. Unit Tests
salissadiq commented 1 month ago

This issue is linked to the approved issue here