Skip to content

coast-framework/env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

env

Easy clojure environment variables

Quickstart

Given an .env file in the root of your project directory:

A_VALUE=hello
(ns your-project
  (:require [env.core :as env]))

(env/env :a-value) ; => hello

Install

Add this to your deps.edn

coast-framework/env {:mvn/version "1.0.3"}}

Usage

Given a .env file above or the equivalent env.edn

Conventions

Notice system environment variables and values in .env are all upper and snake case, while the env.edn variables are all lower, kebab case keywords.

{:a-value "hello"}

This will return "hello"

(env/env :a-value)

Tagged literals

env.edn has one trick up it's sleeve, tagged literals. You can set a #env tagged literal to grab a value from the actual environment and commit env.edn without committing the secret to source control.

env.edn (committed to source control)

{:a-secret-value #env :session-key}

.env (not committed to source control)

SESSION_KEY=123456
COAST_ENV=dev
(env/env :a-secret-value) ; => "123456"

Running the tests

cd env && make test

Releases

No releases published

Packages

No packages published