Before running the project, make sure you have the following prerequisites installed on your machine:
- Java Development Kit (JDK) 17 or higher - Download JDK
- Maven - Download Maven
- Integrated Development Environment (IDE) - recommend use IntelliJ IDEA
Follow the steps below to run the project locally:
-
Open your terminal
-
Choose the folder where the project will be saved
-
Clone the repository to your local machine
git clone [email protected]:TaylorHudson/CompassUOL-SP-Challenge-03-Squad-8-TaylorHudson.git
- Navigate to the project directory
cd CompassUOL-SP-Challenge-03-Squad-8-TaylorHudson
- Compile the Microservices using Maven
cd eureka-server
mvn clean install
cd ..
cd ms-auth
mvn clean install
cd ..
cd ms-gateway
mvn clean install
cd ..
cd ms-notification
mvn clean install
cd ..
cd ms-products
mvn clean install
- Run the Spring Boot application
cd eureka-server
mvn spring-boot:run
cd ms-auth
mvn spring-boot:run
cd ms-gateway
mvn spring-boot:run
cd ms-notification
mvn spring-boot:run
cd ms-products
mvn spring-boot:run
Below are listed the available endpoints in this API:
This endpoint allows creating a new resource.
- firstName: The first name of the user.
- lastName: The last name of the user.
- email: The email of the user.
- password: The password of the user (The password must contain at least 8 characters).
- roles: Permissions that define which resources the user will be able to access (By default the ROLE of id 1 - ADMIN and id 2 - OPERATOR).
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/register' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"password": "john.doe123",
"roles": [2]
}'
Adjust the request body as needed to provide the updated user information.
This endpoint allows updating a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- firstName: The first name of the user.
- lastName: The last name of the user.
- email: The email of the user.
- password: The password of the user (The password must contain at least 8 characters).
- roles: Permissions that define which resources the user will be able to access (By default the ROLE of id 1 - ADMIN and id 2 - OPERATOR).
Use the following cURL command to make the call:
curl --location --request PUT 'http://localhost:8000/users/ID' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data-raw '{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"password": "john.doe321",
"roles": [1, 2]
}'
Replace the token in the Authorization header and the example ID in the endpoint URL with the actual token and user ID you want to update. Adjust the request body as needed to provide the updated user information.
This endpoint allows you to find a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/users/ID' \
--header 'Authorization: Bearer TOKEN' \
Replace the token in the Authorization header and the example ID in the endpoint URL with the actual token and user ID you want to find.
This endpoint allows you to login.
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"password": "john.doe123"
}'
This endpoint allows creating a new resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- name: The name of the product (The product name must be at least 2 characters long).
- description: The last name of the user (The product description must be at least 5 characters long).
- price: The price of the user (The product price must be greater than 0).
- imgUrl: URL that leads to a product image.
- categories: Categories of the product (By default the CATEGORY of id 1 - Electronic and id 2 - Apparel).
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/products' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "Product 1",
"description": "The new generation product 1",
"price": 1000.00,
"imgUrl": "",
"categories": [1]
}'
Replace the token in the Authorization header with the actual token. Adjust the request body as needed to provide the product information.
This endpoint allows you to find a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- name: The name of the product (The product name must be at least 2 characters long).
- description: The last name of the user (The product description must be at least 5 characters long).
- price: The price of the user (The product price must be greater than 0).
- imgUrl: URL that leads to a product image.
- categories: Categories of the product (By default the CATEGORY of id 1 - Electronic and id 2 - Apparel).
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/products/ID' \
--header 'Authorization: Bearer TOKEN' \
Replace the token in the Authorization header and the example ID in the endpoint URL with the actual token and product ID you want to find.
This endpoint allows you to find all resources.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- page (default: 0): Specifies the page number for pagination.
- direction (default: asc): Specifies the sorting direction (asc or desc).
- orderBy (default: price): Specifies the field by which the results should be sorted.
- linesPerPage (default: 10): Specifies the number of product items to be displayed per page.
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/products?page=0&direction=desc&orderBy=name&linesPerPage=5' \
--header 'Authorization: Bearer TOKEN' \
Replace the token in the Authorization header with the actual token.
This endpoint allows updating a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- name: The name of the product (The product name must be at least 2 characters long).
- description: The last name of the user (The product description must be at least 5 characters long).
- price: The price of the user (The product price must be greater than 0).
- imgUrl: URL that leads to a product image.
- categories: Categories of the product (By default the CATEGORY of id 1 - Electronic and id 2 - Apparel).
Use the following cURL command to make the call:
curl --location --request PUT 'http://localhost:8000/products/ID' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "Product 3",
"description": "The new generation product 3",
"imgUrl": "",
"price": 3000.0,
"categories": [1]
}'
Replace the token in the Authorization header and the example ID in the endpoint URL with the actual token and product ID you want to update. Adjust the request body as needed to provide the updated product information.
This endpoint allows deleting a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- name: The name of the product (The product name must be at least 2 characters long).
- description: The last name of the user (The product description must be at least 5 characters long).
- price: The price of the user (The product price must be greater than 0).
- imgUrl: URL that leads to a product image.
- categories: Categories of the product (By default the CATEGORY of id 1 - Electronic and id 2 - Apparel).
Use the following cURL command to make the call:
curl --location --request DELETE 'http://localhost:8000/products/ID'
Replace the token in the Authorization header and the example ID in the endpoint URL with the actual token and product ID you want to update. Adjust the request body as needed to provide the updated product information.
This endpoint allows creating a new resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
- name: The name of the role.
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/roles' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "ROLE_..."
}'
Replace the token in the Authorization header with the actual token. Adjust the request body as needed to provide the created role information.
This endpoint allows you to find all resources.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
Use the following cURL command to make the call:
curl --location 'http://localhost:8000/roles' \
--header 'Authorization: Bearer accessToken' \
Replace the token in the Authorization header with the actual token.
This endpoint allows updating a resource.
- Authorization: The access token provided in the request header. Replace the token in the example with a valid access token.
Use the following cURL command to make the call:
curl --location --request PUT 'http://localhost:8000/roles/ID' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "ROLE_..."
}'
Replace the token in the Authorization header with the actual token.