View Source JetExt.Config.Env (jet_ext v0.2.3)

This module is used to get environment variables.

The most common use case is to import this module in config files.

Example

# runtime.exs
import Config
import JetExt.Config.Env

config :some_app,
  string: fetch_string!("STRING_ENV"),
  integer: fetch_integer!("INTEGER_ENV")

Summary

Functions

Casts an environment variable to a boolean.

Fetches an environment variable and parses it to an integer.

Fetches an environment variable and returns it as a string.

Types

@type options() :: [hint: String.t(), default: any()]

Functions

@spec cast_boolean(name :: String.t()) :: boolean()

Casts an environment variable to a boolean.

Any string except "false" and "0" will be cast to true. Here are some truthy values: "true", "1", "yes", "on".

Link to this function

fetch_integer!(name, options \\ [])

View Source
@spec fetch_integer!(name :: String.t(), options()) :: integer()

Fetches an environment variable and parses it to an integer.

Options:

  • default: the default value to return if the environment variable is missing
  • hint: a hint to be used in the error message, it can contain %{name} which will be replaced by the environment variable name
Link to this function

fetch_string!(name, options \\ [])

View Source
@spec fetch_string!(name :: String.t(), options()) :: String.t()

Fetches an environment variable and returns it as a string.

Options:

  • default: the default value to return if the environment variable is missing
  • hint: a hint to be used in the error message, it can contain %{name} which will be replaced by the environment variable name