Skip to content

Instantly share code, notes, and snippets.

@ezra-chu
Forked from bhauman/core.cljs
Last active April 10, 2019 08:06
Show Gist options
  • Save ezra-chu/0e6d53720cf06b86f1119eb2eda03402 to your computer and use it in GitHub Desktop.
Save ezra-chu/0e6d53720cf06b86f1119eb2eda03402 to your computer and use it in GitHub Desktop.
Using lumo-cljs to run an Express server
(ns server.core
(:require
[cljs.nodejs :as nodejs]))
; Bring in `express` and `http` modules.
(defonce express (nodejs/require "express"))
(defonce http (nodejs/require "http"))
; Create our app.
(def app (express))
; Mount GET handler.
(. app (get "/hello"
(fn [req res] (. res (send "Hello world")))))
; Listen on port 3000.
(doto (.createServer http #(app %1 %2))
(.listen 3000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment