Surgex v0.2.0 Surgex.Config
Application config getter, aka. Application.get_env on steroids.
This getter embodies the usage of {:system, "ENV_VAR_NAME"} convention for managing configs via
system env vars on environments like Heroku. This convention is further extended here to allow
type casting and falling back to defaults in such tuples.
Configs are assumed to live in app-specific parent scope, which is by default set to :surgex,
but should be set to actual application name. Then, all Mix configs that will be fetched via
Surgex.Config should be nested in that scope.
Here’s how your prod.exs may look:
config :surgex,
config_app_name: :my_project
config :my_project,
pool_size: {:system, "POOL_SIZE", :integer, 5},
feature_x_enabled: {:system, "FEATURE_X_ENABLED", :boolean, false}
config :my_project, :api,
url: {:system, "API_URL"},
enabled: {:system, "API_ENABLED", :boolean, true}
In other env configs, like
config.exsanddev.exs, you’ll usually follow the Elixir convention to simply fill the relevant keys with hard-coded values, optionally extracting them to*.secret.exsgitignored files to hold out-of-repo settings.
Having that, you can use either get/1 or get/2 to get specific config values in all envs.