An example REST API based on Pedestal & Duct.
This project shares the data models with lagenorhynque/aqoursql, an example GraphQL API.
- Java (JDK)
java --version>= 11
- Leiningen
- Docker
When you first clone this repository, run:
$ lein duct setupThis will create files for local configuration, and prep your system for the project.
# Start local DB
$ docker compose up -d
# Import DB schema
$ docker compose exec -T mariadb mariadb -uroot -proot aqoursql < sql/ddl/aqoursql.sql
$ docker compose exec -T mariadb-test mariadb -uroot -proot aqoursql_test < sql/ddl/aqoursql.sql
# Seed DB
$ docker compose exec -T mariadb mariadb -uroot -proot aqoursql < sql/dml/seed.sqlTo begin developing, start with a REPL.
$ lein replWith rebel-readline:
$ lein rebelThen load the development environment.
user=> (dev)
:loadedRun go to prep and initiate the system.
dev=> (go)
:duct.server.http.jetty/starting-server {:port 9999}
:initiatedBy default this creates a web server at http://localhost:9999.
When you make changes to your source files, use reset to reload any
modified files and reset the server.
dev=> (reset)
:reloading (...)
:resumedRun halt to halt the system.
dev=> (halt)
:halted$ lein uberjar
$ DATABASE_URL="..." java -jar target/clj-rest-api.jarTesting is fastest through the REPL, as you avoid environment startup time.
dev=> (test)
...But you can also run tests through Leiningen.
$ lein testwith cloverage:
$ lein test-coverage
# Open the coverage report
$ open target/coverage/index.html$ lein lint$ make lint- fixing formatting
$ make cljstyle-fixAPI Documentation (Codox)
$ lein codox
$ open target/codox/index.html