hngprojects / hng_boilerplate_expressjs

75 stars 85 forks source link

[FEAT]: Endpoint to allow Super admin to permanently delete an organisation #144

Open Emeriego opened 3 months ago

Emeriego commented 3 months ago

Description

Implement an API endpoint for permanently deleting an organization. This endpoint allows only authenticated super admin users to delete an organization permanently from the system.

Endpoint Feature

This endpoint enables authenticated super admin users to permanently delete an organization. The Super Admin is limited to deleting organizations by their unique identifier. Once deleted, the organization and all its associated data cannot be recovered. It is permanent.

Acceptance Criteria

Request Example

DELETE /api/v1/organizations/12345/delete Content-Type: application/json Authorization: Bearer

Response Example

On successful deletion of the organization, the API should return a 200 OK status code. The response body should contain a success message:

{
  "status": "success",
  "status_code": 200,
  "message": "Organization deleted successfully."
}

Data Validation

Input Validation:

{
  "status": "unsuccessful",
  "status_code": 400,
  "message": "Valid organization ID must be provided."
}

Output Validation:

Ensure the response format is correct and includes appropriate status codes and messages. If there is an error in deleting the organization (e.g., invalid organization ID, server issues), the API should return a 500 Internal Server Error status code with an appropriate message:

{
  "status": "unsuccessful",
  "status_code": 500,
  "message": "Failed to delete organization. Please try again later."
}

Authentication and Authorization

Authentication:

Authorization:

Error Handling

Error Responses:

{
  "status": "unsuccessful",
  "status_code": 400,
  "message": "Invalid organization ID."
}

Edge Cases:

Performance and Security

Performance Considerations:

Security Concerns:

Documentation

API Documentation:

Technical Notes:

Testing Requirements

Unit Tests:

Integration Tests:

Dependencies and Impact

Dependencies:

Impact Analysis:

incredible-phoenix246 commented 3 months ago

How will u get the user and verify

Yr request body doesn't show that

Update it

Emeriego commented 3 months ago

Thats the work of middleware. The user is expected to be logged in and authenticated.. that does not reflect on the request body. Thats why the Authorization bearer is there. Correct me if i'm wrong.