Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/theavgman/product-rest-resource-quarkus

This is my implementation of a Product REST resource / endpoint / service using the latest cloud-native development Java framework - Quarkus
https://github.com/theavgman/product-rest-resource-quarkus

clean-architecture docker hibernate intellij java json junit maven object-oriented-programming postgresql postman problem-details-for-http-apis quarkus rest-api result-pattern solid-principles

Last synced: about 2 months ago
JSON representation

This is my implementation of a Product REST resource / endpoint / service using the latest cloud-native development Java framework - Quarkus

Awesome Lists containing this project

README

        

🎨💻 Product REST Service using Quarkus 💻🎨

---

## 1 - ✨ Introduction ✨

🎉🥳 Welcome to this repo! 🥳🎉


This is my implementation of a Product REST resource / endpoint / service

using the latest cloud-native development Java framework - Quarkus

The following technologies were used for this task:



REST API
Java
Quarkus
Maven
Hibernate
IntelliJ
Postman
JUnit
PostgreSQL
Docker
Swagger

## 2 - ✨ Running The Database ✨


Before starting the application itself, you must run the database first.

The database is going to be executed as a docker container from the latest Postgres image.


Execute the following command to run this database container:

```shell script
docker run --name products_pgcontainer -e POSTGRES_PASSWORD=secret123 -d -p 5432:5432 -v products_pgdata:/var/lib/postgresql/data postgres
```

## 3 - ✨ Running The Application ✨


Now you need to clone this repo to run the application.

After cloning, open the project in your IDE by clicking on the pom.xml file.


Then you can run the application using one of the following two ways:

I) - Running the application in dev mode

You can run (and re-run) the application in dev mode, which enables live coding using the following command:

```shell script
./mvnw clean compile quarkus:dev
```

II) - Running the application dockerized

For this method, you need to follow these steps:


  1. Replace localhost with host.docker.internal in application.properties file

    under the src/main/resources directory.
  2. Package this application using the following command:
  3. ```shell script
    ./mvnw clean package
    ```

  4. Build the docker image of this application using the following command:
  5. ```shell script
    docker build -f src/main/docker/Dockerfile.jvm -t ProductResource-REST-Quarkus-jvm .
    ```

    > **_Note:_** This step and the two previous ones are performed only once.

  6. Run a container from this image using the following command:
  7. ```shell script
    docker run -i --rm -p 8080:8080 ProductResource-REST-Quarkus-jvm
    ```

    > **_Note:_** This command is needed every time you want to execute the application as a docker container, because the container is automatically removed when stopped.

## 4 - ✨ The Endpoints ✨


Finally, you can start using the API endpoints of the application!! 🥳🎉


To know all the endpoints available and start trying them out, click the following link:

[Let's try it out !!](http://localhost:8080/q/swagger-ui)

> **_Note:_** When using the POST and PUT endpoints, take care not to set the value of ID field as it's automatically generated.

---

## 👋 That's it 👋



I hope you enjoyed it 😊



Thank you for trying it out ❤