{"id":16563090,"url":"https://github.com/markmhendrickson/park-ranger","last_synced_at":"2026-06-07T11:31:16.024Z","repository":{"id":57319220,"uuid":"83706563","full_name":"markmhendrickson/park-ranger","owner":"markmhendrickson","description":"Establish and manage environment-specific variables, settings and resources","archived":false,"fork":false,"pushed_at":"2017-05-03T16:51:50.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T23:25:02.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/markmhendrickson.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":"2017-03-02T17:36:12.000Z","updated_at":"2017-04-03T17:43:50.000Z","dependencies_parsed_at":"2022-08-26T01:10:19.850Z","dependency_job_id":null,"html_url":"https://github.com/markmhendrickson/park-ranger","commit_stats":null,"previous_names":["markmhx/park-ranger"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markmhendrickson/park-ranger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmhendrickson%2Fpark-ranger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmhendrickson%2Fpark-ranger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmhendrickson%2Fpark-ranger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmhendrickson%2Fpark-ranger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markmhendrickson","download_url":"https://codeload.github.com/markmhendrickson/park-ranger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmhendrickson%2Fpark-ranger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34020187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11T20:38:41.193Z","updated_at":"2026-06-07T11:31:16.006Z","avatar_url":"https://github.com/markmhendrickson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# park-ranger\n\n[![Code Climate](https://codeclimate.com/github/markmhx/park-ranger/badges/gpa.svg)](https://codeclimate.com/github/markmhx/park-ranger)\n[![Code Climate issues badge](https://codeclimate.com/github/markmhx/park-ranger/badges/issue_count.svg)](https://codeclimate.com/github/markmhx/park-ranger/issues)\n[![David badge](https://david-dm.org/markmhx/park-ranger.svg)](https://david-dm.org/markmhx/park-ranger)\n\nThis repository contains the source code for a Node module that helps with the management of environment-specific dependencies such as environment variables, configuration files and SSL certificate files.\n\n## Setup\n\nTo include this module in your package, simply run:\n\n``` \nnpm install park-ranger --save\n```\n\nThen add the following to your code:\n\n```\nvar ranger = require('park-ranger')();\n```\n\n## Environment name\n\nBy default, Park Ranger will load dependencies for the app depending on the value of environment variable `ENV_NAME` (with no spaces). As such, you can optionally call your app with the following assignment to make this variable available upfront:\n\n```\nENV_NAME=example node index.js\n```\n\nThe name will be used to determine the files that Park Ranger attempts to locate in your project's base directory and use as dependencies.\n\n| Dependency                        | Filename (no ENV_NAME)      | Filename (ENV_NAME=example) |\n| :-------------------------------- | :-------------------------- | :-------------------------- |\n| Environment variables file        | .env                        | .env-example                |\n| Configuration file                | .config.json                | .config-example.json        |\n| SSL certificate directory         | .cert                       | .cert-example               |\n\n## Environment variables\n\nEnvironment variable files can be made available in [INI format](https://en.wikipedia.org/wiki/INI_file). By default, all variables found in these files will be applied automatically to `process.env` upon load of Park Ranger as a module. They will also be made available as the `env` property of the ranger.\n\nVariables already available in `process.env` will be overwritten by any of those in the file with the same name. All variables will also be made available in the `env` property of the ranger.\n\nIf the ranger is loaded with `true` as a parameter, then the environment variables will *not* be applied automatically to `process.env` but just the `env` property of the ranger. This is useful for accessing the environment variables in a task runner but not incurring the unintended consequence of setting them prematurely for tasks themselves.\n\n#### Example #1 – no ENV_NAME\n\n##### .env file\n\n```\nFOO=BAR\nWHIZ=BANG\n```\n\n##### index.js file\n\n```\nvar ranger = require('park-ranger')();\nconsole.log(ranger.env.FOO);\nconsole.log(process.env.WHIZ);\n```\n\n##### command\n\n```\nnode index.js\n```\n\n##### output\n\n```\nBAR\nBANG\n```\n\n--------\n\n#### Example #2 – ENV_NAME=test\n\n##### .env-test file\n\n```\nDB_NAME=test-db\nSEND_EMAIL=false\n```\n\n##### index.js file\n\n```\nvar ranger = require('park-ranger')();\nconsole.log(ranger.env.DB_NAME);\nconsole.log(process.env.SEND_EMAIL);\nconsole.log(ranger.env.ENV_NAME);\n```\n\n##### command\n\n```\nENV_NAME=test node index.js\n```\n\n##### output\n\n```\ntest-db\nfalse\ntest\n```\n\n--------\n\n#### Example #3 – local environment variables only\n\n##### .env-task-runner file\n\n```\nFOO=BAR\nWHIZ=BANG\n```\n\n##### index.js file\n\n```\nvar ranger = require('park-ranger')(true);\nconsole.log(ranger.env.FOO);\nconsole.log(process.env.FOO);\nconsole.log(ranger.env.ENV_NAME);\n```\n\n##### command\n\n```\nENV_NAME=task-runner node index.js\n```\n\n##### output\n\n```\nBAR\nundefined\ntask-runner\n```\n\n## Configuration files\n\nConfiguration files can be made available in JSON format and must have \".json\" as an extension. Their format should be documented in the parent repository using [MSON](https://github.com/apiaryio/mson) and will get loaded by the ranger into its `config` property.\n\nThese files have an advantage over environment variable files since they can nest properties and generally represent more complex settings. However, they are not applied to `process.env` and therefore rely on the ranger object for access.\n\n#### Example\n\n##### .config.json file\n\n```\n{\n  \"foo\": \"bar\",\n  \"things\": [ 1, 2, 3 ]\n}\n```\n\n##### index.js file\n\n```\nvar ranger = require('park-ranger')();\nconsole.log(ranger.config.foo);\nconsole.log(ranger.config.things.length); \n```\n\n##### command\n\n```\nnode index.js\n```\n\n##### output\n\n```\nbar\n3\n```\n\n--------\n\n## SSL certificate files\n\nCertificate files can be made available in a directory and should correspond to a given certificate's private key, intermediate certificate authority (CA) and server certificate.\n\nThe names of these files can vary, with the following filenames supported:\n\n| Certificate file                  | Filenames supported         |\n| :-------------------------------- | :-------------------------- |\n| Private key                       | key, privkey.pem            |\n| Intermediate CA                   | ca, chain.pem               |\n| Server certificate                | crt, cert.pem               |\n\nThe content of these files will be loaded into the `cert` property of the ranger with corresponding properties \"key\", \"ca\" and \"crt\" representing the file contents. As such, the `cert` property can be used to create an HTTPS server without additional file parsing.\n\n#### Example\n\n##### .cert directory\n\n- privkey.pem\n- chain.pem\n- cert.pem\n\n##### index.js file\n\n```\nvar ranger = require('park-ranger')();\nrequire('https').createServer(ranger.cert, function(req, res) { ... }).listen(443, () =\u003e {\n  console.log('listening!');\n});\n```\n\n##### command\n\n```\nnode index.js\n```\n\n##### output\n\n```\nlistening!\n```\n\n--------\n\n## gitignore\n\nWith all of these files, make sure they are included in the parent respository's \".gitignore\" file so they are not committed to version control.\n\n```\n.env*\n.cert*\n.config*\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmhendrickson%2Fpark-ranger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkmhendrickson%2Fpark-ranger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmhendrickson%2Fpark-ranger/lists"}