Skip to content

Introducing the Application

The application we will be working with today is a simple UI & API pair that provides a way to store and visualize blog posts. The application components can be found at the following links:

In this workshop we will be primarily working with the API, but the UI can be used to see how the application all comes together.

⚠ The UI requires node20.X in order to run properly. Node is not a requirement for the workshop, neither is getting the UI up and running.

Application Cheat Sheet

API

Build

docker run -e GRADLE_USER_HOME='/app/.gradle' -e SPRING_PROFILES_ACTIVE=local --rm -v "$(pwd)":/app -w /app eclipse-temurin:17-jdk ./gradlew --info --no-daemon bootJar
docker build -t dks-api:$(git rev-parse --short HEAD) . 
make docker-build

Run

docker run --name copilot-catalyst-dks-api -p 8080:8080 --rm dks-api:$(git rev-parse --short HEAD)
make up

GET (blog) posts

curl http://localhost:8080/posts/

POST (blog) posts

curl -X POST -H "Content-Type: application/json" -d '{"title":"My Title", "firstName":"My Name", "link":"https://copilot.liatr.io/"}' http://localhost:8080/posts

Generating Mock Data for API Testing

In order to test our new `putPost` method, we will generate some mock data using a bash script.

Follow these steps:

a. Create a new bash script file (e.g., `generate_data.sh`).

b. Add the following code to the script:

```shell
#!/bin/bash

for i in {1..100}
do
  curl -X POST -H "Content-Type: application/json" -d '{
      "title": "Post '"$i"'",
      "firstName": "Author '"$i"'",
      "link": "http://example.com/post/'"$i"'"
  }' http://localhost:8080/posts
done
```

c. Make the script executable by running `chmod +x generate_data.sh`.

UI

Build

npm install

Run

npm run dev