Clojurescript and nodejs

Here’s a little snippet for driving express from clojurescript (run in cljs repl):

(ns express_sample
  (:require [cljs.nodejs :as node]))

(def express (node/require "express"))
(def app (express))

(defn -main [& args]
  (doto app
    (.get "/" (fn [req res]
                (.send res "Hello World")))
    (.listen 3000)))

(-main)
Written on February 13, 2015