A light Biff wrapper around Aero.
Includes a Biff module for parsing a
config.edn file from your resources with Aero and merging it into the system
map. Also defines some reader tags for Aero:
#biff/env: like#envbut also reads dotenv-style values from aconfig.envfile.#biff/secret: like#biff/envbut wraps values incom.biffweb.core/secret-delay.
Also merges a :biff.config/system-properties map from your config into the
system properties, if set.
com.biffweb/config {:mvn/version "2.0.0-rc26"}This library will be a release candidate until all the other Biff 2 libraries have been released. Until then there could be breaking changes, but I don't anticipate any.
Add a resources/config.edn to your project and ensure "resources" is on the
classpath. Put env vars in a config.env file in the working directory (and
list it in .gitignore, of course).
If you're using biff.core, register the module:
(require '[com.biffweb.config :as biff.config])
(def modules [(biff.config/module) ...])
(def start-order [:biff.config/module ...])Without biff.core, call the module's start function directly:
((:biff.core/start (biff.config/module)) {})
=> {...}If you register schema, biff.core will enforce it when *assert* is true:
(require '[com.biffweb.core :as biff.core])
(biff.core/register
{:com.example/client-id :string
:com.example/client-secret :biff.core/secret})Use the :biff.core/secret schema for secrets.
-
See an example resources/config.edn from the demo project.
-
Prefer flat, namespaced keys over namespaced config (
:foo.bar/baz "quux"instead of:foo {:bar {:baz "quux"}} -
When using biff.core, biff.config should be the interface between the config in your environment and the rest of your system. Your other code should always get config values from the system map instead of reading values from the environment directly.
-
I used to use a different env var name for each environment (e.g.
MY_API_KEY_DEVandMY_API_KEY_PROD) and then put conditional logic insideresources/config.ednvia Aero's#profiletags. This is what Biff v1 does by default. I've since decided that it's cleaner to simply have different env var values but the same names for each environment (i.e. the normal way), and I no longer use#profileat all. Up to you.