Simple ToDo app containing REST API written in Java and Kotlin using:
- Spring Data JPA
- Flyway Migration Tool
- PostgresDB 12 (scripts)
- JUnit5
To properly set up and run the app perform following steps:
- Create
todo_db
database in Postgres DB ver 12 using following credentials: username=postgres
password=postgres
NOTE: Make sure they are matchingspring.datasource.username
/spring.flyway.user
properties inapplication.properties
file - Enter directory of
todo-kotlin-java-app
module - Make sure property
spring.flyway.enabled
is set totrue
located insrc/main/resources/application.properties
- Execute
./gradlew bootRun
command - Before 2nd and every other app run (i.e. before executing Step4) set
spring.flyway.enabled
property tofalse
located insrc/main/resources/application.properties
If you prefer not to have needed Postgres 12 version installed on your computer locally you can run docker-compose. In that use case you need to:
- Disable port 5432 in order for containerized Postgres image to run
- Create docker network named
app_db_net
.
Finally, execute docker compose up -d
command to start both application and database containers.
Target one of following endpoints
- GET all Todo(s) http://localhost:8080/api/todos
- GET Single Todo (with id=1) http://localhost:8080/api/todos/1
- POST Todo http://localhost:8080/api/todos
...using following body
{
"title": "Kotlin app review",
"description": "Survive the Kotlin app review"
}
- PATCH Todo http://localhost:8080/api/todos/3
...using following body
{
"title": "Push created Kotlin project!!!"
}
- DELETE Todo http://localhost:8080/api/todos/2