This is a Demo project which purpose is to showcase a small service which uses Liquibase for a tutorial I wrote. During the making of this project I wanted to also try a Reactive approach to connect with the Database by using R2DBC.
The API reads from a database with the following tables and relations.
- Docker Desktop - To run your containerized PostgreSQL database
- Postman - To test the API
-
Install Docker Desktop if you haven't.
-
Run the script
re-start-local-postgres.shlocated in thescriptsfolder to spin up a local version of the Postgres database.
scripts/stop-local-postgres.sh - Run the app with gradle
./gradlew clean bootRun
When the app runs, the Liquibase plugin will run too and the main-changelog.yml will execute all the database changes on it.
This project includes a Postman Collection that you can download to see requests examples for each endpoint. The following table describes briefly each endpoint.
| Method | Endpoint | Description |
|---|---|---|
GET |
/sizes |
List all available sizes. This project contains pre-defined sizes, uploaded through a Liquibase dataset, check the dataset.prod.sql file. |
GET |
/colors |
List all available colors. This project contains pre-defined colors, uploaded through a Liquibase dataset, check the dataset.prod.sql file. |
GET |
/products |
List all available products, by default is empty. Use the POST /products endpoint to add products. |
GET |
/products/{product_id} |
Get the details of a specific product. By default the products table is empty. Use the POST /products endpoint to add products. |
POST |
/products |
Creates a product, you can include colors and sizes associated to the product. See the Postman Collection included in the project to see a request example. |
PUT |
/products/{product_id} |
Updates a product including its associated colors and size. See the Postman Collection included in the project to see a request example. If no colors or sizes are included all associated colors or sizes will be removed. |
DELETE |
/products/{product_id} |
Deletes a product and the colors and sizes associated to it. |
GET |
/products/{product_id}/colors |
List the colors associated to a product. Notice you get the same colors when requesting the details of a product. |
GET |
/products/{product_id}/sizes |
List the sizes associated to a product. Notice you get the same sizes when requesting the details of a product. |
