hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
181 stars 105 forks source link

[FEAT]: Develop API Endpoints for Profile Settings #83

Closed LivingHopeDev closed 1 month ago

LivingHopeDev commented 1 month ago

Description

Create an API endpoint to allow users to view their profile settings. The user must be signed in to view their details.

Acceptance Criteria

}


- Error Handling

   - Unauthorized Access

{ "status": "string", "message": "string", "statusCode": 401 }


## Purpose
Provide an endpoint for users to view their profile settings.

## Requirements
- [ ] Implement an endpoint to retrieve user profile settings.
  - [ ] `GET /api/v1/profile` to retrieve the current user's profile settings.
- [ ] Ensure the endpoint handles authentication securely.
  - [ ] Require users to be signed in to access the endpoint.
  - [ ] Return `401 Unauthorized` if the user is not authenticated.
- [ ] Handle responses and errors appropriately.
  - [ ] Return `200 OK` with the user's profile settings on successful retrieval.
  - [ ] Return all error responses in JSON format with an `error` field containing a descriptive message.

## Unit test

 - GET /api/v1/profile Endpoint:

    - Test that the endpoint returns the user's profile settings correctly.
    - Mock the data access layer to simulate different scenarios.
    - Verify that the response includes all expected fields (profile picture, username, pronouns, job title, etc.).

## End-to-End Tests
- Authenticated User:

   - Setup: Authenticate a test user.
   - Action: Send a GET request to /api/v1/profile.
   - Assertions: Verify 200 OK status.
   - Verify the response includes all expected fields.

- Unauthenticated User:

  - Setup: Ensure no user is authenticated.
  - Action: Send a GET request to /api/v1/profile.
  - Assertions: Verify 401 Unauthorized status.
  - Verify the response contains the correct error message.

- Profile Data Integrity:

  - Setup: Create and authenticate a test user.
  - Action: Send a GET request to /api/v1/profile.
  - Assertions: Verify 200 OK status.
  - Verify the response data matches the stored profile data.

## Expected Outcome
A set of API endpoints that enable users to manage their profile settings seamlessly.

### 
markessien commented 1 month ago

Split Write from Read as tickets, and split the updating of the users profile picture into another ticket

LivingHopeDev commented 1 month ago

This issue has been split as instructed. I am working on #122 . This issue will be closed.

LivingHopeDev commented 1 month ago

This issue has been split as instructed. I am working on #122 . This issue will be closed.

LivingHopeDev commented 1 month ago

I am reopening this issue because I haven't been able to get my team lead for #122 to attend to the comment made by the mentor. I have tried to reach him severally but no response from him for the last 24 hours.

The mentor's comment "Success Response formatting is not standard". I have updated it. .