dotenv_conf

Easy configurations from environment variables and .env files.

Package Version Hex Docs

dotenv_conf uses environment variables by default, and if they do not exist, look at whether the value is defined in a .env file.
That simplifies the dev process while allowing 12-factor configuration for other environments.

Quick start

gleam add dotenv_conf
import dotenv_conf

type Context {
  Context(
    database_path: String,
    application_port: Int
  )
}

pub fn main() {
  use file <- dotenv_conf.read_file(".env")
  let context = Context(
    database_path: dotenv_conf.read_string_or("DB_PATH", file, "[memory]"),
    application_port: dotenv_conf.read_int_or("PORT", file, 8000)
  )

  // use the context after that
}

Further documentation can be found at https://hexdocs.pm/dotenv_conf.

Roadmap

Search Document