Sample REST backend on JDBC written in Clojure.
- Language Clojure
- State management Component
- SQL access HugSQL
- DB connection pool HikariCP
- DB migrations Flyway
- HTTP server Ring
- Routes definition Compojure
- Logging Logback
- Tests Midje
- DB tests LightAir
- Production deployment as a .jar or .war
- "Reloaded" workflow in REPL
- Comprehensive integration tests that exercise the application from the HTTP handler down to the database
- CRUDL on entities: project, user, session
- Authentication and authorization
Migrate database (bring DB structure up-to-date)
lein db-migrate
Clean database
lein db-clean
Cleanly re-create database
lein db-recreate
Update LightAir DB structure (call after each change in DB tables)
lein db-update
-
Start application via Leiningen
lein ring server-headless
Changes to source code are not supported in this mode, see REPL below.
-
Invoke application
curl -i -X POST -H "Content-Type: application/json" -d '{ "code" : "code-1", "name" : "Name 1", "visibility" : "private" }' "http://localhost:3000/projects"
-
Open REPL
lein repl
-
Load development environment
(dev)
-
Start system
(go)
-
Invoke application
Reload application after changing the source code
(reset)
Stop system
(stop)
Start system
(start)
Update LightAir DB structure (call after each change in DB tables)
(db-update)
Migrate database
(db-migrate)
Clean database
(db-clean)
Cleanly re-create database
(db-recreate)
Run all tests
lein test
This includes also the integration tests so the system gets started (and stopped).
After the system has started and the database has been migrated
(autotest)
-
Build and package for production
lein uberjar
-
Run in production
java -jar target/uberjar/clojure-rest-jdbc-backend-*-standalone.jar
Build and package for production
lein uberwar
WAR is built at
target/uberjar/clojure-rest-jdbc-backend-*-standalone.war
and is deployable on a default installation of Tomcat 7.0.57.
Copyright © 2016 Ivo Maixner
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.