lib/ex_the_one/config.ex
defmodule ExTheOne.Config do
@moduledoc since: "0.1.0"
use Application
def start(_type, _args) do
unless Mix.env() == :prod do
Envy.auto_load()
end
# List all child processes to be supervised
children = []
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: ExTheOne.Supervisor]
Supervisor.start_link(children, opts)
end
@doc """
Prints the ExTheOne API key stored as an environment variable.
## Examples
iex> ExTheOne.Config.api_key
"123456789"
"""
def api_key do
Envy.load([".env"])
Application.get_env(:ex_the_one, :api_key) || System.get_env("THE_ONE_API_KEY")
end
end