{"action":"opened","issue":{"url":"https://api.github.com/repos/hemanth/nmotw.in/issues/38","repository_url":"https://api.github.com/repos/hemanth/nmotw.in","labels_url":"https://api.github.com/repos/hemanth/nmotw.in/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/hemanth/nmotw.in/issues/38/comments","events_url":"https://api.github.com/repos/hemanth/nmotw.in/issues/38/events","html_url":"https://github.com/hemanth/nmotw.in/issues/38","id":175791621,"number":38,"title":"Easiest way to handling env. var-based configuration for everything","user":{"login":"FGRibreau","id":138050,"avatar_url":"https://avatars.githubusercontent.com/u/138050?v=3","gravatar_id":"","url":"https://api.github.com/users/FGRibreau","html_url":"https://github.com/FGRibreau","followers_url":"https://api.github.com/users/FGRibreau/followers","following_url":"https://api.github.com/users/FGRibreau/following{/other_user}","gists_url":"https://api.github.com/users/FGRibreau/gists{/gist_id}","starred_url":"https://api.github.com/users/FGRibreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FGRibreau/subscriptions","organizations_url":"https://api.github.com/users/FGRibreau/orgs","repos_url":"https://api.github.com/users/FGRibreau/repos","events_url":"https://api.github.com/users/FGRibreau/events{/privacy}","received_events_url":"https://api.github.com/users/FGRibreau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-08T15:53:55Z","updated_at":"2016-09-08T15:53:55Z","closed_at":null,"body":"Category: configuration\r\n\r\n> [common-env](https://github.com/FGRibreau/common-env)\r\n> common-env configuration through environment variables finally done right.\r\n\r\n```js\r\n// test.js\r\n\r\nconst env = require('common-env')();\r\n// also try:\r\n// const env = require('common-env/withLogger')(console);\r\n\r\nconst config = env.getOrElseAll({\r\n  amqp: {\r\n    login: 'guest',\r\n    password: 'guest',\r\n    host: 'localhost',\r\n    port: 5672\r\n  }\r\n});\r\n\r\nconsole.log(config.amqp.port); // number\r\n```\r\n\r\nAMQP_PORT=1010 node test.js\r\n\r\nIt's DRY, it follows 12 factors (no configuration files), it supports default values, variable arrays, automatic type conversion, password protection everything that is a constant in your code can use it... easy right?\r\n"}}
{"actor":{"display_login":"FGRibreau"}}