An open API service indexing awesome lists of open source software.

https://github.com/ammbot/config_env

Configuration loader from system environment
https://github.com/ammbot/config_env

elixir

Last synced: 4 months ago
JSON representation

Configuration loader from system environment

Awesome Lists containing this project

README

          

# ConfigEnv

**Configuration loader from system environment**

## Why?
ensure that all system environment is set and convert to properly type.

## Installation

First, add ConfigEnv to your mix.exs dependencies:
```elixir
def deps do
[
{:config_env, "~> 0.1.0"}
]
end
```
## Usage

in `config.exs`
```elixir
config :your_app,
string: {:system, "KEY"},
atom: {:system, "ATOM"},
integer: {:system, "INTEGER", :integer},
float: {:system, "FLOAT", :float},
list: {:system, "LIST", :list}
```
it can be nested
```elixir
config :your_app,
nested: %{
key: {:system, "KEY"},
another_nested: [
key: {:system, "ANOTHER_KEY"}
]
}
```
put this code before start your app
```elixir
defmodule YourApp do
use Application

def start(_type, _args) do
ConfigEnv.load_env([:yourapp, :otherapp, ...])
# your code
end

```