CLI utility in ClojureScript running on Node.js
-
Upload
karolis-labrencis -
Category
Technology
-
view
62 -
download
0
Transcript of CLI utility in ClojureScript running on Node.js
Clojure on NodeBuilding a CLI utility
Why?• Startup speed - Node.js apps start faster• Easier distribution -- ```npm install -g
<app>```• Way to learn core.async• AWS Lambda/Google Cloud Functions
(serverless architecture)• Server-side rendering
ClojureScript build process
*.cljs files
*.js file(s)
Google Closurecompiler
ClojureScriptcompiler
compiles cljs->js
compilesjs->optimized-js
Setting up Leiningen
Setting up Leinigen (cont'd)
Hello, World!
Building
Read Eval Print Loop demo
REPLstarts
nodejs process on random port
does this:
and sends user commands to nodejs process, started by repl-env, over the network socket
used by IDEs
Parsing ars - clj.tools.cli
Parsing args (cont'd)
Interop with Node.js libraries
compiles into
Callbacks
core.async for callbacks
https://github.com/georgewsinger/cljs-callback-heaven/blob/master/src/cljs_callback_heaven/core.cljs
core.async for callbacks (cont'd)
https://github.com/mailhog/MailHog
core.async for promises
Links• clojars.org/<template-name>/lein-template
=>```lein new <template-name> <project-name>```
• https://clojars.org/cljs-node/lein-template• https://clojars.org/cljs-node-app/lein-template• https://clojars.org/node-cljs/lein-template• https://clojars.org/node-cli/lein-template• https://github.com/karolisl/repomaker -- my cljs-node project• https://github.com/Gozala/node.core -- some helper functions working on
node• https://github.com/GregorStocks/cljs-http-node -- core.async based http
client for node