A headless Blog Entries API
- Java 17+
- PostgreSQL
- Zipkin (Optional)
./mvnw clean package -DskipTests
Run Postgresql and zipkin
docker-compose up
Run the app
java -jar target/blog-api-5.0.0-SNAPSHOT.jar
or
./mvnw spring-boot:run
makes automatically docker compose up
Download a blog entry template
curl -s http://localhost:8080/entries/template.md > template.md
Put a first blog entry from template
curl -s -u admin:changeme -XPUT http://localhost:8080/entries/1 -H "Content-Type: text/markdown" -d "$(cat template.md)"
or if you don't want to specify the entry id, post it
curl -s -u admin:changeme -XPOST http://localhost:8080/entries -H "Content-Type: text/markdown" -d "$(cat template.md)"
Check the entries
$ curl -s http://localhost:8080/entries/1 | jq .
{
"entryId": 1,
"frontMatter": {
"title": "Welcome to CategolJ!",
"categories": [
{
"name": "Blog"
},
{
"name": "Posts"
},
{
"name": "Templates"
}
],
"tags": [
{
"name": "CategolJ"
},
{
"name": "Hello World"
}
]
},
"content": "Welcome\n\n**Hello world**, this is my first Categolj blog post.\n\nI hope you like it!",
"created": {
"name": "admin",
"date": "2022-11-26T08:42:52.032376Z"
},
"updated": {
"name": "admin",
"date": "2022-11-26T08:42:52.032376Z"
}
}
Delete the entry
curl -s -u admin:changeme -XDELETE http://localhost:8080/entries/1
Go to http://localhost:8080/swagger-ui/index.html for the Swagger UI
(/swagger-ui/4.18.2/index.html
for native image)
Set DATABASE_URL
according to your environment as follows.
If you don't have an accessible PostgreSQL instance, please refer to this documentation.
export DATABASE_URL=postgres://username:[email protected]/blog
java -jar target/blog-api-5.0.0-SNAPSHOT.jar
./mvnw -V spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=IMAGE_NAME
You can use ghcr.io/categolj/blog-api:jvm
as a pre-built image
./mvnw -V -Pnative spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=IMAGE_NAME
You can use ghcr.io/categolj/blog-api:native
as a pre-built image
TBD
Licensed under the Apache License, Version 2.0.