hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
182 stars 105 forks source link

[FEAT]: Support for Language Selection Feature #34

Closed Ace2489 closed 2 weeks ago

Ace2489 commented 1 month ago

Description

Implement backend functionality to support a language, region, and time zone selection feature, ensuring preferences are stored and applied correctly across the application.

Acceptance Criteria

  1. Database Schema Update

    • Update the database schema to include user locale — language, region, and time zone.
    • Ensure the schema can accommodate future additions.
  2. API Endpoints Implementation

    • Create an endpoint to update user preferences.
    • Implement an endpoint to retrieve the user's current locale.
    • Develop endpoints to fetch all supported languages, regions, and time zones.
  3. Locale Management

    • Validate inputs against the list of supported parameters.
    • Store preferences securely in the database.
    • Ensure locale preferences are applied consistently across user sessions.
  4. Security and Performance

    • Implement proper authentication and authorization for updates to the user's locale details.
  5. Documentation

    • Create comprehensive API documentation for all new endpoints.
    • Include examples of request/response payloads in the documentation.

Purpose

Provide backend infrastructure to manage and store user locale, enabling a multi-region user experience.

Requirements

Expected Outcome

Successfully store and apply user-selected locale details across the different parts of the application.

Endpoints

Get Supported Languages

Description: Get the languages supported by the system.

GET /api/v1/languages

Response (Success)

 {
  "status": "success",
  "data": 
   {
     "languages": [
      {
        "id": "string",
    "language": "String"
      },
     ]
   }
 }

Response (Error)

 {
    "status": "error",
    "message": "You are not authorised for this action",
    "statusCode": 401
 }

Get Supported Regions

Description: Get the regions supported by the system.

GET /api/v1/regions

Response (Success)

 {
  "status": "success",
  "data": 
   {
     "regions": [
      {
        "id": "string",
    "region": "String"
      },
     ]
   }
 }

Response (Error)

 {
    "status": "error",
    "message": "You are not authorised for this action",
    "statusCode": 401
 }

Get Supported Time Zones

Description: Get the time zones supported by the system.

GET /api/v1/timezones

Response (Success)

 {
  "status": "success",
  "data": 
   {
     "timezones": [
      {
        "id": "string",
    "timezone": "String"
      },
     ]
   }
 }

Response (Error)

 {
    "status": "error",
    "message": "You are not authorised for this action",
    "statusCode": 401
 }

Update The User's Locale

Description: Changes the user's locale details to the specified option

PUT /api/v1/users/locale
 {
    "language": "String",
    "region": "String",
    "timezone": "String"
 }

Response (Success)

 {
    "status": "success",
    "message": "Locale details updated successfully",
    "data": {   
        "language": "String",
    "region": "String",
        "timezone": "String"
       }

 }

Response (Error)

 {
    "status": "error",
    "message": "Invalid locale details passed",
    "statusCode": 422
 }
 {
    "status": "error",
    "message": "You are not authorised for this action",
    "statusCode": 401
 }

Get User Locale

Get the user's current language and region preference

GET /api/v1/users/locale

Response (Success)

 {
    "status": "success",
    "data":
      {
        "language": "String",
    "region": "String",
        "timezone": "String"
      }
 }
 {
    "status": "error",
    "message": "You are not authorised for this action",
    "statusCode": 401
 }

Testing

buka4rill commented 1 month ago

Please remember to version the API

Ace2489 commented 1 month ago

Thank you for the corrections. I have made the updates.

thenoblet commented 1 month ago

@Ace2489, are you working on this with your team?

theijhay commented 1 month ago

@Ace2489 You picked different endpoints while some of us are looking for endpoint to work on. please do something @buka4rill