Hi I am looking to build a simple web app (rest) to get started and familiarize myself with clojure world. Any url or idea or a youtube video that can help me? I would be looking to use 1. Ring 2. Jetty 3. Compojure Thanks
@gaverhae what do you suggest, if not Compojure ?
I am currently exploring so any ideas are welcome
I'm using Reitit, quite happy with it. Never tried Compojure - didn't like some things years ago when I myself was evaluating which libraries to use, but don't remember what exactly. Used Bidi initially but it's rather hard to debug when something goes wrong.
@p-himik thank you, I'll explore Reitit and get back to you!
I think the biggest practical downside to compojure vs. more modern alternatives like reitit — besides the very subjective aesthetic aspect of compojure's macro language — is that since you compose your "route handlers" using macros and functions, routes themselves are not reified, meaning you don't easily have a "single source of truth" that allows you to manage routes in both ways - i.e. compojure gives you handlers for specific routes, but you then have to build out routes yourself (e.g. when making a link), whereas with something like reitit you have a single, reified, data definition of your routes, which you can then use to derive both "route handlers" and "link makers", if that makes sense. That said, I've pretty much always used compojure and that's never been a problem. I think it mostly depends on ow many routes you end up having and how often they change.
The bare minimum is Ring + Jetty (or any other web server for which there's an adapter for Ring). So I'd suggest following through any resource that helps you with Ring, and then going through Compojure docs. An example of such Ring + Jetty article: https://www.baeldung.com/clojure-ring
I found pedestal guide super helpful https://pedestal.io/pedestal/0.7/guides/hello-world.html
Pedestal is not Ring though.
I'd also caution a tiny bit about Compojure. It's great, and I've been using it pretty much since it came out, and I like it quite a bit, and it's still the routing library I reach for because it does everything I need so I never felt the need to really look at other ones. But, it is pretty old, and that means there are a few things that make it not a great example of "modern" Clojure good practices, such as: • It uses macros quite a bit, whereas more modern routing libraries use data. • It has its own destructuring syntax, which is not entirely in line with core Clojure destructuring, which can get confusing, especially as a beginner.
You might find this useful as an example https://github.com/seancorfield/usermanager-example The README also links to a version that uses reitit for routing instead of Compojure, for comparison of the two libraries.
Hey everyone!
I'm running the command clj -Spath with the following minimal deps.edn
{:paths ["src"]
:mvn/repos {"clojars" {:url " "}}
:deps {buddy/buddy-auth {:mvn/version "3.0.323" :exclusions [org.clojure/clojure]}
buddy/buddy-oauth2 {:mvn/version "1.9.0" :exclusions [org.clojure/clojure]}}}
But everytime I run the command, I receive the following error message:
Error building classpath. Could not find artifact buddy:buddy-oauth2:jar:1.9.0 in central ( )
Is there a way to force the CLI tool to search for the dependencies using clojars repository?No need for that :exclusions - Clojure version is not picked up from your dependencies. If you don't specify it in your deps.edn, it will be taken from clj itself.
As for buddy/buddy-oauth2 - where did it come from? It doesn't exist in Clojars, and I can't find anything relevant.
Also, Clojars is searched, no need for that :mvn/repos. It's just that the error reports only Maven Central - maybe because it's being checked last, I don' tknow.
https://github.com/funcool/buddy is presumably the authoritative list of buddy libraries, and it does not mention a buddy-oauth2.
I suspect @petrisrf got that deps.edn from ChatGPT and it hallucinated the library name...?
I think @seancorfield is right. Since I'm new to the ecossystem, I was searching for libraries using ChatGPT...
Hi! Can someone please help me translate this into HoneySql:
["SELECT id, name FROM plugins
WHERE tsv @@ plainto_tsquery('english', ?)
ORDER BY ts_rank_cd(tsv, plainto_tsquery('english', ?)) DESC
LIMIT ? OFFSET ?"])
struggling with ORDER BY ts_rank_cd(tsv, plainto_tsquery('english', ?))
got as far as:
{:select [:id :repo :description]
:from [:plugins]
:where [atat :tsv [:plainto_tsquery 'english q]]
:order-by [[:%ts_rank_cd [:tsv :plainto_tsquery 'english q]] :desc]
:limit limit
:offset offset})))(require '[honey.sql :as sql]
'[honey.sql.pg-ops :as pg-ops])
(let [q ""
limit 10
offset 0]
(sql/format
{:select [:id :repo :description]
:from [:plugins]
:where [pg-ops/atat :tsv [:plainto_tsquery [:inline "english"] q]]
:order-by [[[:ts_rank_cd :tsv [:plainto_tsquery [:inline "english"] q]] :desc]]
:limit limit
:offset offset}))Oh, I see now. Thank you very much!
For queries that stump me, I like to incrementally build up the HoneySQL syntax using the helper functions... https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1310/api/honey.sql.helpers
As I go along, I also visually inspect the string version, by toggling honey.sql/format "on and off" (using #_).
Once done, I typically copy the generated HoneySQL and use that directly in my code. Optionally, the helper code that was built up can also stay in code, except as a comment block for later reference.
Gradually, intuition builds about how to mentally map HoneySQL syntax and compiler rules to the equivalent raw SQL query versions.
(-> {}
(select :a :b :c)
(from :table)
(where [:= :id 42])
#_(sql/format))Nice trick! I am finding quite intuitive, just getting used to nesting.