grav / jadak

Web-server for ClojureScript/NodeJS based on Yada

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jadak

Jadak is a web framework for the NodeJS platform implemented in ClojureScript.

Clojars Project

Jadak, jadak og ... jadak

Jadak, jadak og ... jadak!

Features

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

Getting started

Simple example

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

About

Web-server for ClojureScript/NodeJS based on Yada


Languages

Language:Clojure 100.0%