Episode 011: The Convention of Configuration

Play Episode

Nate is worried about the hardcoded credentials in the code.

Clojure in this episode:

Related projects:

Code sample from this episode:

(ns app.config
  (:require
    [clojure.edn :as edn]
    [environ.core :refer [env]]))

(defn from-env []
  {:twitter-key (or (env :twitter-key) "")
   :twitter-secret (or (env :twitter-secret) "")
   :initial-tweets (or (env :initial-tweets) 20))

(defn config []
  (merge (from-env)
         (edn/read-string (try (slurp "dev.edn") (catch Throwable e "{}")))))