This NestJS application provides user registration service, allowing users to create accounts and store their personal information in a MongoDB database. After registration, a RabbitMQ message is sent to an email microservice, which sends a verification email to the user's email address.
Before you can use this API, you'll need to have the following software installed:
- Node.js (version 18.12.1 or higher)
- npm (version 8.19.2 or higher)
- Docker (version 20.10.8 or higher)
- RabbitMQ (version 3.9.7 or higher)
- MongoDB (version 5.0.15 or higher)
To get started with the API, follow these steps:
- Clone this repository or download the zip file;
- Unzip the file;
- Install the dependencies by running
yarn install
ornpm install
; - Open a terminal window and navigate to the project directory;
- Run
docker compose up
to start the server and all the required services (RabbitMQ, MongoDB and Email microservice).
Unit tests for this API can be run by executing the command yarn test
or npm run test
. These tests are performed using Jest and cover the API's basic functionality.
In order to test in localhost, you need to download the Postman Desktop
The following endpoints are available in the API:
API Endpoints 📡 The following endpoints are available in the API:
POST
/api/users: create a new user account. The request body should contain the user's first_name, last_name, email and avatar file.GET
/api/user/{userId}: get a user by ID.GET
/api/user/{userId}/avatar: get a user's avatar image.DELETE
/api/user/{userId}/avatar: delete a user's avatar image.
- URL:
POST /api/users
- Description: Creates a new user account with the given details.
- Request Body:
Key Value firstName Spider lastName Man email [email protected] avatar Image File - Response Body:
{ "firstName": "Spider", "lastName": "Man", "email": "[email protected]", "id": "98", "createdAt": "2023-04-23T23:25:59.728Z" }
- URL:
GET /api/user/{ObjectId}
- Description: Gets the user with the specified ID.
- Response Body:
{
"data": {
"id": 1,
"email": "[email protected]",
"first_name": "George",
"last_name": "Bluth",
"avatar": "https://reqres.in/img/faces/1-image.jpg"
},
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- URL:
GET /api/user/{ObjectId}/avatar
- Description: Get the user avatar with specified ObjectId
- Response: User avatar image
- URL:
DELETE /api/user/{ObjectId}/avatar
- Description: Delete the user avatar with specified ObjectId
- Response Body:
{
"message": "User avatar deleted successfully",
"status": 200
}