This application is part of the Polar Bookshop system and provides the functionality for managing the books in the bookshop catalog. It's part of the project built in the Cloud Native Spring in Action book by Thomas Vitale.
Endpoint | Method | Req. body | Status | Resp. body | Description |
---|---|---|---|---|---|
/books |
GET |
200 | Book[] | Get all the books in the catalog. | |
/books |
POST |
Book | 201 | Book | Add a new book to the catalog. |
422 | A book with the same ISBN already exists. | ||||
/books/{isbn} |
GET |
200 | Book | Get the book with the given ISBN. | |
404 | No book with the given ISBN exists. | ||||
/books/{isbn} |
PUT |
Book | 200 | Book | Update the book with the given ISBN. |
201 | Book | Create a book with the given ISBN. | |||
/books/{isbn} |
DELETE |
204 | Delete the book with the given ISBN. |
Gradle Command | Description |
---|---|
./gradlew bootRun |
Run the application. |
./gradlew build |
Build the application. |
./gradlew test |
Run tests. |
./gradlew bootJar |
Package the application as a JAR. |
./gradlew bootBuildImage |
Package the application as a container image. |
After building the application, you can also run it from the Java CLI:
java -jar build/libs/catalog-service-0.0.1-SNAPSHOT.jar
Run PostgreSQL as a Docker container
docker run -d \
--name polar-postgres \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=polardb_catalog \
-p 5432:5432 \
postgres:14.4
Docker Command | Description |
---|---|
docker stop polar-postgres |
Stop container. |
docker start polar-postgres |
Start container. |
docker remove polar-postgres |
Remove container. |
Start an interactive PSQL console:
docker exec -it polar-postgres psql -U user -d polardb_catalog
PSQL Command | Description |
---|---|
\list |
List all databases. |
\connect polardb_catalog |
Connect to specific database. |
\dt |
List all tables. |
\d book |
Show the book table schema. |
\quit |
Quit interactive psql console. |
From within the PSQL console, you can also fetch all the data stored in the book
table.
select * from book;