Fork me on GitHub
#biff
<
2023-08-15
>
Clark Urzo10:08:17

Is there any reason for config.edn or secrets.env to not get loaded? When I print my ctx the corresponding values are just the env variable names (e.g. “COOKIE_SECRET” instead of $COOKIE_SECRET)

Jacob O'Bryant15:08:02

it's a feature, not a bug 🙂. secrets are intentionally kept out of ctx so that it's harder to shoot yourself in the foot by accidentally printing out all your secrets/serializing them somewhere. instead, secrets are stored in environment variables by default, and there's a helper function (stored in ctx) that can read them for you:

(defn my-handler [{:keys [biff/secret]}]
  (println (secret :biff.middleware/cookie-secret))
...
another benefit of having this extra layer of indirection is that you can override the secret fn implementation if you're using something other than env variables to store your secrets. it's also compatible with loading the secrets only when you use them at runtime instead of loading them all at system startup.

clojure-spin 2
Jacob O'Bryant15:08:46

I.e. the values from config.edn are only ever used to provide the names of the corresponding env vars

Jacob O'Bryant15:08:40

the main reason I wanted to bake this into biff (instead of letting people just update their codebases if they switch away from env vars) is that the biff library code needs to read secrets, so I wanted it to have some kind of stable interface for doing so that wouldn't need to change

Clark Urzo01:08:43

Thanks! I realised I was already doing it this way before and I just forgot 😅

🙌 2
ianjones15:08:56

has anyone set up Lucene for full text search with biff? It looks relatively simple from the xtdb set up section but it never seems like things go that smoothly 😛 Im using xtdb with postgres on DO

Jacob O'Bryant20:08:23

haven't done it myself, but good luck 🙂 happy to help troubleshoot if you run into any problems

gonzalnt10:08:53

Hi @U0CKDV6DB, I setup full text search with biff using the following Update deps.edn add the following line.

com.xtdb/xtdb-lucene {:mvn/version "1.23.3"}
Update config.edn add the following line
:biff.xtdb/opts 
  {:xtdb.lucene/lucene-store {}}
See the line 35 and 36 on the attached screenshot.

🙌 2
ianjones16:08:12

very cool, thanks!

👍 2