Jadak is a web framework for the NodeJS platform implemented in ClojureScript.
Jadak, jadak og ... jadak!
Jadak implements a subset of the Yada web library. Among Jadak's features are:
- declarative route definitions (via Bidi)
- Basic and Cookie authentication
- CORS support
- EDN and JSON encoding and decoding
- easy usage in AWS Lambda
Here we create a single route, /hello
that just responds "world"
. We then use the listener
function to
serve the route with the built-in http-server in NodeJS:
(require '[jadak.jadak :as jadak])
(def routes
["/hello" (jadak/resource {:methods {:get {:produces #{"text/plain"}
:response (fn [_] "world")}}})])
(jadak/listener
routes
{:port 8000})
We can run it with Lumo by saving it as hello.cljs
and running:
$ lumo -c`clojure -Sdeps '{:deps {jadak {:mvn/version "0.1.3"}}}' -Spath` hello.cljs
Now we can test it using curl
:
$ curl http://localhost:8000/hello
world