hngprojects / hng_boilerplate_expressjs

75 stars 83 forks source link

[FEAT]: API Endpoint for Getting All Users With Pagination(Super admin) #124

Open 26thavenue opened 1 month ago

26thavenue commented 1 month ago

Description

Implement an API endpoint for retrieving all users with pagination. This endpoint allows authenticated super admins to fetch a paginated list of all users in the system.

Endpoint feature

Acceptance Criteria

Request Example:

GET /api/v1/users?page=1&limit=10&offset=0 Authorization: Bearer

Response Example:

On successful retrieval of users, the API should return a 200 OK status code. The response body should contain a paginated list of users:

{
  "status": "success",
  "status_code": 200,
  "data": {
    "users": [
      {
        "id": 1,
        "username": "user1",
        "email": "user1@example.com",
        "role": "admin",
        "created_at": "2024-07-22T10:00:00Z"
      },
      {
        "id": 2,
        "username": "user2",
        "email": "user2@example.com",
        "role": "user",
        "created_at": "2024-07-22T11:00:00Z"
      }
    ]
  }
}

Data Validation

Input Validation:

{
  "status": "unsuccessful",
  "status_code": 400,
  "message": "Invalid pagination parameters. Page and limit must be positive integers."
}

Output Validation

Authentication and Authorization

Authentication

Authorization

Error Handling

Error Responses

Edge Cases

Documentation

API Documentation:

Technical Notes:

Testing Requirements

Unit Tests:

Integration Tests

Dependencies and Impact

Dependencies

Impact Analysis

AdeGneus commented 1 month ago

Good issue