braidchat / braid

Braid is a team-chat app with a novel UI that leads to better conversations.
http://www.braidchat.com/
Other
923 stars 53 forks source link

Improve config parsing #234

Closed rafd closed 3 years ago

rafd commented 3 years ago

braid.base.api/register-config-var! allows modules to declare optional or required config vars (read from mount-args).

https://github.com/braidchat/braid/blob/master/src/braid/base/api.cljc#L149

Ex. braid.embeds-map does: (base/register-config-var! :google-maps-api-key)

However:

Part 1:

Part 2:

Below is some related code I pulled from another project:

(defn parse [config schema]
  (if (malli/validate (malli.util/closed-schema schema) config)
    config
    (let [cause (malli/explain (malli.util/closed-schema schema) config)]
      (throw
       (ex-info (str "Config invalid\n"
                     (with-out-str
                       (pprint/pprint (malli.error/humanize cause)))) cause)))))