{"id":16019449,"url":"https://github.com/iboard/exconfig","last_synced_at":"2025-03-18T03:31:16.068Z","repository":{"id":57500116,"uuid":"183893301","full_name":"iboard/exconfig","owner":"iboard","description":"A configuration cache for Elixir, reading from `Application.get_env` and `System.get_env`","archived":false,"fork":false,"pushed_at":"2021-08-17T09:26:46.000Z","size":113,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T13:38:36.854Z","etag":null,"topics":["configuration","elixir","elixir-lang"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/exconfig","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iboard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-28T10:26:28.000Z","updated_at":"2021-08-15T19:22:54.000Z","dependencies_parsed_at":"2022-08-28T20:01:16.322Z","dependency_job_id":null,"html_url":"https://github.com/iboard/exconfig","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Fexconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Fexconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Fexconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Fexconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iboard","download_url":"https://codeload.github.com/iboard/exconfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243896638,"owners_count":20365408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","elixir","elixir-lang"],"created_at":"2024-10-08T17:04:24.042Z","updated_at":"2025-03-18T03:31:15.807Z","avatar_url":"https://github.com/iboard.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exconfig\n\n[![Documentation](https://img.shields.io/badge/docs-hexpm-blue.svg)](http://hexdocs.pm/exconfig/)\n[![Documentation](https://travis-ci.com/iboard/data_source.svg?branch=master)](https://travis-ci.com/iboard/exconfig)\n\n- [At Github](https://github.com/iboard/exconfig)\n- [Hex](https://hex.pm/packages/exconfig)\n\n## Context\n\nDon't use ENV-settings for compile-time configuration. (Because it is\nhard to maintain your environment-settings for different deployments.\n\nImagine you want to build a Docker-image for your Phoenix-application\nand you use something like\n\n```elixir\n   plug SomePlug, config_value: System.get_env(\"SOME_KEY\")\n```\n\n`plug` is a macro and therefore, `SOME_KEY` gets evaluated at\ncompile time. If `SOME_KEY` is customer-related, this setting\nget's burned into the image and may surprisingly pop up at the\nwrong customer's server.\n\nThe `Exconfig`-package will help you not to make this mistake.\nJust use `Exconfig.get` instead of all your `Application.get_env`\nand `System.get_env` calls. Because the cache-server of `Exconfig`\nwill not run at compile-time you'll get a compile-error if you\ntry to use System-envs from your busines-logic.\n\n## Usage\n\nThe application starts a GenServer and caches configuration at run time.\n\nLoading configuration happens in two steps where each step overwrites\neventually existing values from previous steps.\n\n  - Application.get_env(:app, :key) default\n  - System.get_env(:key) default\n\nOnce the value is cached it will be returned from the GenServer state\nrather than re-reading it from the environment again.\n\nUsing `Exconfig.clear_cache!/0` will drop the cache and values will be\nloaded again if being accessed later.\n\n### Example:\n\n    iex\u003e value = Exconfig.get(:my_app, :foo, \"bar\" )\n    \"bar\"\n\n    iex\u003e value = Exconfig.get(:env, :some_secret )\n    nil\n\n`Exconfig.get/3` will first lookup for :myapp/:foo in the Exconfig.Cache \n(a GenServer) and if not found load from `Application`, `System`, or\nreturns the default. The second example will read from env-var SOME_SECRET.\nBecause no default value is given, it will return `nil`\n\n## configuration.log\n\n`Exconfig.get/3` is a macro. At compile-time in any environment but `:prod`,\nit will capture it's usage in a file. The file can be configured in `config.ex`\nand defaults to `configuration.log`.\n\nThe File can be used as a template for a shell-script.\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/exconfig). The package can be installed\nby adding `Exconfig` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:exconfig, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\nDocumentation can be generated with `mix docs` ([ExDoc](https://github.com/elixir-lang/ex_doc))\nand is published at [https://hexdocs.pm/exconfig](https://hexdocs.pm/exconfig).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Fexconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiboard%2Fexconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Fexconfig/lists"}