Fork me on GitHub
#biff
<
2022-03-31
>
geraldodev22:03:14

Is it possible to use biff and not use xtdb ? Or Does biff depends on xtdb to run ? I'm interested on biff for, authentication , malli and htmx, and simple system composition. Any of these components depends on xtdb ?

Jacob O'Bryant23:03:15

You could take out xtdb without too much work. those components can all be used without xtdb. Out of curiosity, do you have another database in mind you'd be replacing it with? (postgres/datomic?) authentication only uses xtdb when creating a new user, so you'd just need to replace this bit: https://github.com/jacobobryant/biff/blob/master/example/src/com/example/feat/auth.clj#L76-L82 In general, assuming you're starting from a newly created biff project, you'd just need to go through the code and mechanically replace any calls to submit-tx, q and entity with the equivalents for whatever database you use instead. And also remove the use-xt and use-tx-listener components. The one bit that might be difficult is replacing use-tx-listener actually (which powers the :on-tx features), depending on what database you're using. (e.g. with datomic I think you could replace it fairly easily; don't know about postgres). You could also get by with just leaving it out altogether.

geraldodev23:03:56

The authentication would use ldap and the database is oracle. no tx listening for without bags of gold (not our case). I would use mostly to search a database. the libraries you use are very nice. and for not using xtdb. I'd rather not use it as my single source of truth, due to it would require to manage a postgres and a xtdb on top of it.

👍 1
Jacob O'Bryant23:03:49

One more thing I just remembered that you'd need to do: there is a wrap-env middleware function that adds a :biff/db key to incoming requests. It's a couple layers down, within the biff/use-outer-default-middleware component (https://github.com/jacobobryant/biff/blob/master/example/src/com/example.clj#L83). You'd need to define a custom use-outer-default-middleware component and use that instead:

(defn wrap-env [handler sys]
  (fn [req]
    (handler (merge sys req))))

(defn wrap-outer-defaults [handler opts]
  (-> handler
      (biff/wrap-ring-defaults opts)
      (wrap-env opts)))

(defn use-outer-default-middleware [sys]
  (update sys :biff/handler wrap-outer-defaults))

geraldodev23:03:10

Correct me if I'm wrong but Rum is used in biff just to generate static files right ? Biff is positioned to be a server side clojure framework.

Jacob O'Bryant23:03:48

Rum is used both for generating static files and for dynamic server-side rendering. No client-side rendering. It is a server side framework.