{"id":23814241,"url":"https://github.com/stuartpb/envigor","last_synced_at":"2025-09-06T23:31:56.494Z","repository":{"id":8619756,"uuid":"10262431","full_name":"stuartpb/envigor","owner":"stuartpb","description":"Env-var-to-config-object generator","archived":false,"fork":false,"pushed_at":"2015-08-18T22:35:58.000Z","size":338,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-14T12:10:11.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stuartpb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-24T08:35:20.000Z","updated_at":"2019-07-26T10:30:16.000Z","dependencies_parsed_at":"2022-08-26T04:43:32.320Z","dependency_job_id":null,"html_url":"https://github.com/stuartpb/envigor","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fenvigor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fenvigor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fenvigor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fenvigor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuartpb","download_url":"https://codeload.github.com/stuartpb/envigor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232149969,"owners_count":18479564,"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":[],"created_at":"2025-01-02T03:46:58.530Z","updated_at":"2025-01-02T03:46:59.065Z","avatar_url":"https://github.com/stuartpb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# envigor\n\n[![Build Status](https://img.shields.io/travis/stuartpb/envigor.svg)](https://travis-ci.org/stuartpb/envigor)\n\nenvigor is a module that creates configuration objects for several\nmodules and backing services based on what environment variables are available.\n\nThis is useful for automatically deciding configuration options for\n[twelve-factor apps](http://12factor.net/) that run in environments like\nHeroku, where several different choices of addon can be provisioned to provide\nthe same service: calling `envigor` will check the environment variables for\nall known service providers (and a general set of variables for any services\nthat may be set up manually / in-house), then create a config object that will\nconnect to that service regardless of provider (envigor objects can usually be\npassed directly to the setup function of multiple drivers).\n\n## Usage\n\nThe constructor returned by `require('envigor')` takes an object of environment\nvariables (using [`process.env`][1] by default), then returns a uniform object\ncontaining the configuration properties specified by that environment.\n\n[1]: https://iojs.org/api/process.html#process_process_env\n\nSay you're making an Express app with MongoDB, that you're writing for a\nplatform like Heroku, with addons like MongoLab to provide your more general\nservices like MongoDB. By using envigor, you can set your app up to find a\nconfigured MongoDB service with complete provider agnosticism:\n\n```bash\nnpm install --save envigor mongodb\nheroku addons:add mongolab\n```\n\nserver.js:\n```js\nvar http = require('http')\nvar cfg = require('envigor')();\n\nvar app = require('./app.js')(cfg);\nhttp.createServer(app).listen(cfg.port || 5000, function() {\n  console.log(\"Listening on \" + port);\n});\n```\n\napp.js:\n```js\nvar express = require('express');\nmodule.exports = function(cfg){\n  var app = express();\n\n  mongodb.MongoClient.connect(cfg.mongodb.url,function(err,db){\n    if(err) throw err; else app.set('db',db)\n  }\n\n  // ...your routes here...\n\n  return app;\n}\n```\n\nWith envigor, the structure of the app server is so common and lightweight that\nit is provided as a binary with the library named `envigorate`. Using\n`envigorate`, the only scaffolding you need to run an app is, in package.json:\n\n```json\n  \"main\": \"app.js\",\n  \"scripts\": {\n    \"start\": \"envigorate\"\n  }\n```\n\n(And you can technically leave out that first line if you use `index.js`\ninstead of `app.js`.)\n\n[![freaky baby from portugese milk commercial](http://i.imgur.com/IkKRoLd.jpg)](http://garfadasonline.blogspot.com/2011/02/o-quarto-de-leite-vigor.html)\n\n# Configuration\n\nIn the root `index.js`, envigor only adds a few properties:\n\n- `port`, the value of the almost-inescapable `PORT` variable, used for setting\n  the port for a server to listen on\n- `ip`, the value of the `IP` variable, used in some environments to specify a\n  specific network interface to listen on\n- `database`, described in detail in the \"database\" section below\n- `env`, the environment variables used to construct the configuration\n\nEvery other object in envigor is set by a script in `lib/cfg`, with a minimal\noverview described below (read the files themselves for full details as to the\nenvironment variables that can give the corresponding values).\n\n## cors\n\nHeaders for Cross-Origin Resource Sharing. Goes great with\n[ach](https://github.com/stuartpb/ach).\n\nNote that allowOrigin and possibly maxAge are the only CORS configuration\nparameters that are likely to be deployment-specific, and as such are the only\nvariables you should be setting through the environment / `envigor()`. While\nthe rest are gathered by envigor, it's mostly for symmetry; they're more likely\nto be specific to your code, and as such should be ignored / clobbered by\nstatic strings when you set up CORS.\n\ncors is also aliased as accessControl.\n\n- allowOrigin\n- allowCredentials\n- exposeHeaders\n- maxAge\n- allowMethods\n- allowHeaders\n\n## email\n\n**Adds:** smtp, mandrill, postmark, sendgrid, mailgun\n\n### smtp\n\n- username, user, auth.user\n- password, pass, auth.pass\n- hostname, host, server\n- port\n- service\n\n### mandrill\n\n[Mandrill](http://mandrill.com/) by MailChimp\n\n- username\n- apiKey, password\n\n### postmark\n\nhttps://postmarkapp.com\n\n- apiKey\n- inboundAddress\n\n### sendgrid\n\nSendGrid (http://sendgrid.com)\n\n- username\n- password\n\n### mailgun\n\n[Mailgun](http://www.mailgun.com/): Programmable Mail Servers\n\n- apiKey\n- smtp\n  - username, user, login\n  - password, pass\n  - hostname, host, server\n  - port\n\n## mongodb\n\n**Services:** [mongolab][], [mongohq][] (aliased as compose.mongodb)\n\n[mongolab]: https://mongolab.com/\n[mongohq]: https://www.compose.io/\n\n- url, uri\n\n## redis\n\n**Services:** [rediscloud][], [redistogo][], [myredis][], [openredis][],\n[redisgreen][]\n\n[rediscloud]: http://redis-cloud.com/\n[redistogo]: http://redistogo.com/\n[myredis]: http://myredis.com/\n[openredis]: https://openredis.com/\n[redisgreen]: http://www.redisgreen.net/\n\n- url\n- hostname\n- port\n- password\n- database\n\nThe individual fields will by default be gathered from url using the form\n`redis://database:password@hostname:port` if url is defined: if not, url\nwill be constructed from these fields.\n\nYou can also set `DEFAULT_REDIS` to populate redis with all the default\nvalues.\n\n## memcache\n\n**Services:** [memcachier][], [memcachedcloud][]\n\n[memcachier]: https://www.memcachier.com/\n[memcachedcloud]: http://garantiadata.com/memcached\n\n- servers, as an array split on semicolons and commas in the defined\n  variable. To reconstruct the string, use `servers.join(',')`.\n- username\n- password\n\nYou can also set `DEFAULT_MEMCACHE` to populate `memcache` with all the default\nvalues.\n\n## mysql\n\n**Services:** [cleardb][]\n\n[cleardb]: http://www.cleardb.com/\n\n- url\n\n## neo4j\n\n**Services:** [graphenedb][], [graphstory][]\n\n[graphenedb]: http://www.graphenedb.com/\n[graphstory]: http://graphstory.com/\n\n- url\n\n## rabbitmq\n\n**Services:** [rabbitmqBigwig][], [cloudamqp][]\n\n[rabbitmqBigwig]: https://rabbitmq-bigwig.lshift.net/\n[cloudamqp]: http://www.cloudamqp.com/\n\nrabbitmq is also aliased as amqp.\n\n- url\n- tx.url\n- rx.url\n\n## rethinkdb\n\n- hostname, host, server\n- port\n- database, db\n- authKey, auth\n- table\n\n## arangodb\n\n- url\n\n## postgresql\n\n- url\n\nNote that, while `DATABASE_URL` is conventionally used to refer to a PostgreSQL\ndatabase on Heroku, envigor **does not** use `DATABASE_URL` as a fallback\nname for the PostgreSQL URL. If you wish to have this behavior, add this\nline after your call to `require('envigor')();`.\n\n```\ncfg.postgresql = cfg.postgresql || cfg.database;\n```\n\n## database\n\n*(Per the note in the section introduction, this is added in index.js.)*\n\nThe \"database\" hash, if present, contains the content of `env.DATABASE_URL` in\nits url field.\n\nUse of \"database\" / `DATABASE_URL` is discouraged, and is included primarily\nfor the use of applications with legacy configuration schemas.\n\nNote that, while `DATABASE_URL` is conventionally used to refer to a PostgreSQL\ndatabase on Heroku, envigor **does not** use `DATABASE_URL` as a fallback\nname for the PostgreSQL URL. See the section on `postgresql`.\n\n## bitcoin\n\nRPC interfaces for cryptocurrency daemons patterned after bitcoind\n\n**Adds:** bitcoin, litecoin, dogecoin\n\n- hostname, host\n- port\n- username, user\n- password, pass\n\n## amazonaws\n\nAmazon Web Services\n\n**Adds:** aws, s3\n\n### aws\n\n- accessKey\n- secret\n\n### s3\n\n- accessKey, key\n- secret\n- bucket\n- endpoint\n\n## facebook\n\nFacebook App configuration\n\n- appId, clientID\n- secret, clientSecret\n\n## reddit\n\nReddit App configuration\n\n- username\n- password\n- appId, clientID, consumerKey, oauth.consumerKey\n- secret, clientSecret, consumerSecret, oauth.consumerSecret\n\n## twitter\n\nTwitter application OAuth credentials\n\n- key, consumerKey\n- secret, consumerSecret\n\n## twilio\n\nThe [Twilio](http://www.twilio.com) cloud communications platform\n\n- accountSid\n- authToken\n- number\n\n## recaptcha\n\nreCAPTCHA - http://www.google.com/recaptcha\n\n- privateKey\n- publicKey\n\n## firebase\n\nhttps://www.firebase.com/\n\n- secret\n- url\n- appName\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fenvigor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartpb%2Fenvigor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fenvigor/lists"}