hngprojects / hng_boilerplate_expressjs

75 stars 85 forks source link

[FEAT]: API Endpoint to Update a Single User Profile #136

Open aniebietafia opened 3 months ago

aniebietafia commented 3 months ago

Description

Implement an endpoint that allows registered and authenticated users to update their profile.

Endpoint Features

Acceptance Criteria

API Endpoint

PUT /api/v1/users/:user_id

Request Example

{
  "firstName": "John"
}

Response Example

{
  "message": "Profile updated successfully",
  "status_code": 200,
  "data": {
    "id": "wr54dgh-67dnut763-t36ud89",
    "firstName": "John",
    "lastName": "Doe",
    "location": "Nigeria",
    "created_at": TimeStamp,
    "updated_at": TimeStamp
  }
}

Data Validation

Input Validation

{
  "status_code": 422,
  "message": "Validation failed",
  "errors": {
    "firstName": "First name is a string",
    "lastName": "Last name is a string",
    "location": "Location is a string"
  }
}

Authentication and Authorization

Authentication

{
  "status_code": 401,
  "message": "Unauthorized"
}

Authorization

{
  "status_code": 403,
  "message": "Forbidden"
}

Error Handling

Error Response

{
  "status_code": 404,
  "message": "User not found"
}
{
  "status_code": 500,
  "message": "Internal server error"
}

Security

Documentation

Testing

incredible-phoenix246 commented 3 months ago

Sorry for not updating you

It is now update profile alone

So no preference

aniebietafia commented 3 months ago

Alright. Thanks

aniebietafia commented 3 months ago

I have updated the ticket.