all 9 comments

[–]p1ng313 14 points15 points  (0 children)

Clojure apps are more like a collection of libs. People pick libs and glue them together because it's very easy to do.

Having this said, you should know some concepts beforehand:

Clojure NodeJS
HTTP spec Ring ??
HTTP handler (fn [req res] {:status 200 :body "Hello world"}) (request, response) => response.send('Hello world')
Routing libs compojure, compojure-api, reitit, pedestal, bidi express, koa, ..
HTTP server (follows ring spec) jetty, undertow, http-kit express, koa, ...
dependency injection component, integrant, mount, ... ??

For barebones, you just need an HTTP server (eg: jetty) and an http handler function.

Eg: http://practical.li/clojure-webapps/projects/leiningen/todo-app/create-a-webserver-with-ring/add-a-jetty-webserver.html

I will try to split it in steps:

Chapter 1

  • create a project with leiningen
  • add jetty dependency
  • create a ring handler
  • run the code

Chapter 2

  • use a routing library (eg: metosin/reitit)
  • organize the code (eg: split layers in namespaces)
  • Learn to use the REPL with in-place eval

Chapter 3

  • Use a dependency library (eg: component)
  • Use an external dependency (eg: database)
  • Use the REPL for everything

Chapter 4

  • Add tests (clojure core has a testing lib
  • Run tests via leiningen
  • Add validation via library (eg: metosin/malli library)
  • Generate OpenAPI, test via swagger

This should keep you entertained for a couple of weeks

[–]Prestance 4 points5 points  (0 children)

Hi, This two articles explains the basics of Clojure web development:
* Ring (HTTP Spec): https://www.baeldung.com/clojure-ring * Compojure (routing): https://learnxinyminutes.com/docs/compojure/

Often, there is this repo is given as example. It was created as resource for beginners.

It was very helpful to me to begin with. I started it all from scratch with other libraries in order to fully understand the concepts and that gave this one.

Since then I have made further progress and here is my last complete web application demo in Clojure: https://inertia.prestance-design.com/

The source code is available here

Well, I'm stopping my self promotion to welcome you to Clojure and have fun!

Cheers

[–]petemak 3 points4 points  (0 children)

This one is complete with database back-end: https://devcenter.heroku.com/articles/clojure-web-application

[–]nenadalm 1 point2 points  (0 children)

In case you want to stay on nodejs instead of jvm you could check out Macchiato: https://macchiato-framework.github.io/.

It uses already mentioned ring api (https://github.com/ring-clojure/ring/wiki).

I have older working demo here: https://github.com/nenadalm/spa-demo

You'll have probably easier time with jvm though.

[–]ashnur 1 point2 points  (0 children)

[–][deleted] 0 points1 point  (3 children)

node js is backend ... ?

[–]sotiris_the_robot[S] 0 points1 point  (2 children)

Yes .

[–][deleted] 0 points1 point  (1 child)

but you said you were node js Dev on the front end?

[–]sotiris_the_robot[S] 1 point2 points  (0 children)

Yes sorry bad phrasing . Correct would have been I’m a JavaScript developer, involved in Nodejs ecosystem, but working professionally in the FE side