I'm trying some deno stuff. Any chance to get something like this to run?
(ns server)
(def port 8080)
(defn handler [req]
(let [agent (-> req (.-headers) (.get "user-agent"))
body (str "Your user agent is: " (or agent
"Unknown"))]
(new js/Response body #js {:status 200})))
(-> Deno
.serve handler #js {:port port})
I'm invoking with
deno run -A npm:nbb server.cljs
Currently, it is not finding the global Deno object, but there might be a lot of other issues.The global Deno object can be found with js/Deno
This script works with your invocation:
(ns server)
(def port 8080)
(defn handler [req]
(let [agent (-> req (.-headers) (.get "user-agent"))
body (str "Your user agent is: " (or agent
"Unknown"))]
(new js/Response body #js {:status 200})))
(js/Deno.serve handler #js {:port port})The threading macro invocation should have been:
(-> js/Deno (.serve handler #js {:port port}))@borkdude thanks A LOT! I can't believe this isn't hyped more, I find this to be frickin' awesome. I have a datastar sample I'm going to incorporate. If it works it would be like 20 lines of code and nearly 0 setup. I'm excited!
Had written a cljs project that uses deftype implementing the ILookup protocol from cljs.core. When importing it into nbb, it throws the following error:
ILookup does not exist
Am I just importing ILookup from the wrong source or are protocols just not supported in nbb currently?built-in CLJS protocol implementations on deftypes are currently not supported in SCI
Thanks