API to manage madoxx bar tea and snacks catalog.
first thing first, start the PostgreSQL database:
docker-compose up -drun in dev mode that enables live coding using:
./gradlew quarkusDevinitialize or reset the database with sample data:
curl -X POST http://localhost:8080/api/seed/initialize -H 'Content-Type: application/json'Response: {"message":"Base de dados inicializada com sucesso","seeded":true}
curl -X POST http://localhost:8080/api/seed/reset -H 'Content-Type: application/json'Response: {"message":"Base de dados resetada com sucesso","seeded":false}
curl -X GET http://localhost:8080/api/seed/statusResponse: {"seeded":true} or {"seeded":false}
curl -X GET http://localhost:8080/api/seed/dataResponse (if seeded):
{
"teas": [],
"snacks": [],
"sauces": [],
"total": {
"teas": 4,
"snacks": 3,
"sauces": 5
}
}Response (if not seeded): {"message":"Database not seeded"}
curl -X GET http://localhost:8080/teascurl -X GET 'http://localhost:8080/teas?paginated=false'curl -X GET 'http://localhost:8080/teas?page=0&size=10'curl -X GET 'http://localhost:8080/teas?category=GREEN&paginated=false'Available categories: BLACK, GREEN, HERBAL, OOLONG, WHITE, FLORAL, OTHER
curl -X GET 'http://localhost:8080/teas?caffeineLevel=MEDIUM&origin=japan&paginated=false'Available caffeine levels: NONE, LOW, MEDIUM, HIGH
curl -X GET http://localhost:8080/teas/{id}curl -X POST http://localhost:8080/teas \
-H "Content-Type: application/json" \
-d '{
"name": "Sencha",
"origin": "japan",
"description": "Japanese green tea",
"ingredients": [
{
"name": "Green Tea Leaves",
"quantity": 5.0,
"unitOfMeasure": "GRAMS"
}
],
"category": "GREEN",
"caffeineLevel": "MEDIUM"
}'curl -X PUT http://localhost:8080/teas/{id} \
-H "Content-Type: application/json" \
-d '{
"name": "Sencha Premium",
"origin": "japan",
"description": "Premium Japanese green tea",
"ingredients": [
{
"name": "Premium Green Tea Leaves",
"quantity": 6.0,
"unitOfMeasure": "GRAMS"
}
],
"category": "GREEN",
"caffeineLevel": "LOW"
}'curl -X DELETE http://localhost:8080/teas/{id}curl -X DELETE 'http://localhost:8080/teas?category=GREEN'curl -X GET http://localhost:8080/snackscurl -X GET 'http://localhost:8080/snacks?paginated=false'curl -X GET 'http://localhost:8080/snacks?page=0&size=10'curl -X GET 'http://localhost:8080/snacks?vegan=true&paginated=false'curl -X GET 'http://localhost:8080/snacks?flavour=cheese&paginated=false'curl -X GET 'http://localhost:8080/snacks?sauce=spicy&paginated=false'curl -X GET http://localhost:8080/snacks/{id}curl -X POST http://localhost:8080/snacks \
-H "Content-Type: application/json" \
-d '{
"name": "Chips",
"flavour": "Salt",
"vegan": true
}'curl -X PUT http://localhost:8080/snacks/{id} \
-H "Content-Type: application/json" \
-d '{
"name": "Chips Updated",
"flavour": "BBQ",
"vegan": false
}'curl -X DELETE http://localhost:8080/snacks/{id}curl -X DELETE http://localhost:8080/snackscurl -X GET http://localhost:8080/snacks/{id}/saucescurl -X POST http://localhost:8080/snacks/{snackId}/sauces/{sauceId}curl -X DELETE http://localhost:8080/snacks/{snackId}/sauces/{sauceId}curl -X GET http://localhost:8080/saucescurl -X GET 'http://localhost:8080/sauces?paginated=false'curl -X GET 'http://localhost:8080/sauces?page=0&size=10'curl -X GET 'http://localhost:8080/sauces?flavour=spicy&paginated=false'curl -X GET http://localhost:8080/sauces/{id}curl -X POST http://localhost:8080/sauces \
-H "Content-Type: application/json" \
-d '{
"name": "Hot Sauce",
"flavour": "Spicy"
}'curl -X PUT http://localhost:8080/sauces/{id} \
-H "Content-Type: application/json" \
-d '{
"name": "Super Hot Sauce",
"flavour": "Extra Spicy"
}'curl -X DELETE http://localhost:8080/sauces/{id}curl -X DELETE http://localhost:8080/saucescurl -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "admin"
}'Response:
{
"accessToken": "YOUR_JWT_TOKEN",
"expiresIn": 3600,
"refreshToken": "YOUR_REFRESH_TOKEN"
}curl -X POST http://localhost:8080/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "YOUR_REFRESH_TOKEN"
}'Response:
{
"accessToken": "YOUR_NEW_JWT_TOKEN",
"expiresIn": 3600,
"refreshToken": "YOUR_NEW_REFRESH_TOKEN"
}curl -X POST http://localhost:8080/auth/logout \
-H "Authorization: Bearer YOUR_JWT_TOKEN"curl -X GET http://localhost:8080/auth/me \
-H "Authorization: Bearer YOUR_JWT_TOKEN"Response:
{
"username": "admin",
"email": "admin@maddoxbar.com",
"roles": ["USER", "ADMIN"]
}# List only active users (default)
curl -X GET http://localhost:8080/auth/users \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# List all users (active and inactive)
curl -X GET 'http://localhost:8080/auth/users?active=' \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# List only inactive users
curl -X GET 'http://localhost:8080/auth/users?active=false' \
-H "Authorization: Bearer YOUR_JWT_TOKEN"Response:
[
{
"username": "admin",
"email": "admin@maddoxbar.com",
"roles": ["USER", "ADMIN"]
},
{
"username": "user",
"email": "user@maddoxbar.com",
"roles": ["USER"]
}
]can be packaged using:
./gradlew buildproduces the quarkus-run.jar file in the build/quarkus-app/ directory.
be aware that it’s not an über-jar as the dependencies are copied into the build/quarkus-app/lib/ directory.
then runnable using java -jar build/quarkus-app/quarkus-run.jar.
if you want to build an über-jar, execute the following command:
./gradlew build -Dquarkus.package.jar.type=uber-jarpackaged as an über-jar, is now runnable using java -jar build/*-runner.jar.
native executable:
./gradlew build -Dquarkus.native.enabled=trueor run the native executable build in a container using:
./gradlew build -Dquarkus.native.enabled=true -Dquarkus.native.container-build=trueand, yes. it has swagger-ui too: http://localhost:8080/swagger-ui
also, ill try to keep this updated. :D
this is a work in progress. see next-steps.md for upcoming features and technical roadmap.