{"id":16144232,"url":"https://github.com/ryanj/cloud-env","last_synced_at":"2025-03-18T17:31:47.766Z","repository":{"id":21913710,"uuid":"25237838","full_name":"ryanj/cloud-env","owner":"ryanj","description":"Consistent naming for cloud-provided server configs","archived":false,"fork":false,"pushed_at":"2018-08-23T23:29:46.000Z","size":20,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T22:36:01.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.org/package/cloud-env","language":"JavaScript","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/ryanj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-15T03:45:22.000Z","updated_at":"2019-08-13T15:52:58.000Z","dependencies_parsed_at":"2022-08-17T23:35:20.110Z","dependency_job_id":null,"html_url":"https://github.com/ryanj/cloud-env","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanj%2Fcloud-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanj%2Fcloud-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanj%2Fcloud-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanj%2Fcloud-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanj","download_url":"https://codeload.github.com/ryanj/cloud-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244269587,"owners_count":20426254,"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":"2024-10-10T00:12:00.014Z","updated_at":"2025-03-18T17:31:47.389Z","avatar_url":"https://github.com/ryanj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#cloud-env [![npm version](http://img.shields.io/npm/v/cloud-env.svg)](https://www.npmjs.org/package/cloud-env) [![Build Status](http://img.shields.io/travis/ryanj/cloud-env.svg)](https://travis-ci.org/ryanj/cloud-env)\n\n**!!AUTOCONFIGURE JS CODE FOR USE ON ANY PLATFORM NODE!!**\n\n[cloud-env](https://github.com/ryanj/cloud-env) provides a vendor-neutral interface for autoconfiguring your app, making it portable across all major cloud hosting platforms / deployment targets:\n\n* [OpenShift](https://developers.openshift.com/languages/nodejs/environment-variables.html#listen)\n* [Heroku](https://devcenter.heroku.com/articles/dynos#web-dynos)\n* [Modulus](http://help.modulus.io/customer/portal/articles/1660583)\n* [CloudFoundry](http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#PORT)\n\nIt works by checking the system environment (`process.env`) for known configuration strings, normalizing the results into [a well-defined list](#configuration-strings).\n\n[![npm stats](https://nodei.co/npm/cloud-env.png?downloads=true\u0026stars=true)](https://www.npmjs.org/package/cloud-env)\n\n[![Dependency Check](http://img.shields.io/david/ryanj/cloud-env.svg)](https://david-dm.org/ryanj/cloud-env) [![monthly downloads](http://img.shields.io/npm/dm/cloud-env.svg)](https://www.npmjs.org/package/cloud-env) [![license](http://img.shields.io/npm/l/cloud-env.svg)](https://www.npmjs.org/package/cloud-env)\n\n## Installation\n\nThe resulting config object contains the configuration settings that `cloud-env` was able to detect - including the server `PORT` number and bind `IP` address:\n\n``` js\n  //npm install cloud-env\n  var config = require('cloud-env')\n```\n\nSee the [Configuration Strings](#configuration-strings) list for more information about the settings that this module will automatically resolve.\n\n## Listen up\nMake sure to pass `config.PORT` and `config.IP` to your server's `listen` function:\n\n```js\napp.listen(config.PORT, config.IP, function () {\n  console.log(\"Listening on \"+config.IP+\", port \"+config.PORT)\n});\n```\n\nIf host-provided configs are not found, local development defaults are returned - allowing you to configure once, and run anywhere.\n\n### Provide your own defaults\nUse `.get('KEYNAME', default_value)` to fetch keys by name, optionally providing your own default values:\n\n```js\nport = config.get('PORT', 8000)\nbind_address = config.get('IP','127.0.0.1')\napp.listen(port, bind_address, function () {\n  console.log(\"Listening on \" + bind_address + \", port \" + port)\n});\n```\n\nThe above example will default to port `8000` instead of `8080`, and will attempt to bind on '127.0.0.0.1' instead of '0.0.0.0'.\n\n## Configuration Strings\nReliable configuration settings for local dev AND for \"the cloud\":\n\nconfig.NAME | DEFAULT | process.env.SOURCE_VARS \n--------------------|-----------|---------------\nIP                  | 0.0.0.0 | OPENSHIFT_NODEJS_IP, BIND_IP \nPORT                | 8080  | OPENSHIFT_NODEJS_PORT, PORT\nHOSTNAME            | localhost  | OPENSHIFT_APP_DNS, HOSTNAME \nAPP_NAME            | APP_NAME  | OPENSHIFT_APP_NAME, APP_NAME\nMONGODB_DB_URL      | mongodb://127.0.0.1:27017  | OPENSHIFT_MONGODB_DB_URL, MONGODB_DB_URL\nMONGODB_DB_HOST      | 127.0.0.1  | OPENSHIFT_MONGODB_DB_HOST, MONGODB_DB_HOST\nMONGODB_DB_PORT      | 27017  | OPENSHIFT_MONGODB_DB_PORT, MONGODB_DB_PORT\nMONGODB_DB_USERNAME      | undefined  | OPENSHIFT_MONGODB_DB_USERNAME, MONGODB_DB_USERNAME\nMONGODB_DB_PASSWORD      | undefined  | OPENSHIFT_MONGODB_DB_PASSWORD, MONGODB_DB_PASSWORD\nPOSTGRESQL_DB_URL   | postgresql://127.0.0.1:5432  | OPENSHIFT_POSTGRESQL_DB_URL, POSTGRESQL_DB_URL\nPOSTGRESQL_DB_HOST   | 127.0.0.1  | OPENSHIFT_POSTGRESQL_DB_HOST, POSTGRESQL_DB_HOST\nPOSTGRESQL_DB_PORT   | 5432  | OPENSHIFT_POSTGRESQL_DB_PORT, POSTGRESQL_DB_PORT\nPOSTGRESQL_DB_USERNAME   | undefined  | OPENSHIFT_POSTGRESQL_DB_USERNAME, POSTGRESQL_DB_USERNAME\nPOSTGRESQL_DB_PASSWORD   | undefined  | OPENSHIFT_POSTGRESQL_DB_PASSWORD, POSTGRESQL_DB_PASSWORD\nMYSQL_DB_URL      | mysql://127.0.0.1:3306  | OPENSHIFT_MYSQL_DB_URL, MYSQL_DB_URL\nMYSQL_DB_HOST      | 127.0.0.1  | OPENSHIFT_MYSQL_DB_HOST, MYSQL_DB_HOST\nMYSQL_DB_PORT      | 3306  | OPENSHIFT_MYSQL_DB_PORT, MYSQL_DB_PORT\nMYSQL_DB_USERNAME      | undefined  | OPENSHIFT_MYSQL_DB_USERNAME, MYSQL_DB_USERNAME\nMYSQL_DB_PASSWORD      | undefined  | OPENSHIFT_MYSQL_DB_PASSWORD, MYSQL_DB_PASSWORD\n\n### Advanced Configuration\n\nSee [`config-multipaas`](https://github.com/ryanj/config-multipaas/) and the related [`config-chain` API docs](https://github.com/dominictarr/config-chain/#boring-api-docs) for a more advanced configuration solution that incorporates the same set of cloud configuration keys.\n\n![MultiPaaS](http://i.imgur.com/fCi6YX6.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanj%2Fcloud-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanj%2Fcloud-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanj%2Fcloud-env/lists"}