micro_blog_repo_fetchers/src/micro_blog/config.clj

35 lines
937 B
Clojure

(ns micro-blog.config)
(def ^:private env-overrides
{:pocket-base-pw "POCKET_BASE_PW"
:pocket-base-host "POCKET_BASE_HOST"
:blue-sky-api-key "BLUE_SKY_API_KEY"
:mistral-api-key "MISTRAL_API_KEY"
:mastodon-host "MASTODON_BASE_URL"
:mastodon-account-id "MASTODON_ACCOUNT_ID"
:api-host "API_HOST"
:api-port "API_PORT"
;; :nostr-fetcher-npub "NOSTR_FETCHER_NPUB"
:nostr-fetcher-id "NOSTR_FETCHER_PUB_HEX"
:nostr-id "NOSTR_ID"
:nostr-relay "NOSTR_RELAY"})
(defn- load-config []
(merge (read-string (slurp "config.edn"))
(into {} (for [[k env-var] env-overrides
:let [env-val (System/getenv env-var)]
:when env-val]
[k env-val]))))
(def config (atom (load-config)))
(defn reload []
(reset! config (load-config)))
(comment
;; Example usage:
;; Access the config
@config
;; Reload the config at runtime
(reload))