Skip to content

Instantly share code, notes, and snippets.

@bmaddy
Created February 26, 2013 22:23
Show Gist options
  • Save bmaddy/5042869 to your computer and use it in GitHub Desktop.
Save bmaddy/5042869 to your computer and use it in GitHub Desktop.
(ns cljs-demo.http
(:require [cljs.nodejs :as node]))
(def http
(node/require "http"))
(defn handler [_ res]
(.writeHead res 200 (js-obj "Content-Type" "text/plain"))
(.end res "Hello World!\n"))
(defn start [& _]
(let [server (.createServer http handler)]
(.listen server 1337 "127.0.0.1")
(println "Server running at http://127.0.0.1:1337/")))
(set! *main-cli-fn* start)
$ ~/bin/clojurescript/bin/cljsc foo '{:optimizations :advanced :target :nodejs}' > raw-foo.js
$ node raw-foo.js
/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:162
ype","text/plain"));return b.end("Hello World!\n")}function Gg(){Eg.Lb(Fg).Mb(
^
TypeError: Object #<Object> has no method 'Lb'
at Gg (/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:162:567)
at Hg (/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:162:733)
at Zd (/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:70:59)
at Function.ae [as b] (/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:75:316)
at Object.<anonymous> (/Users/bmaddy/src/sandbox/2013/conbat/raw-foo.js:162:817)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment