{"id":21031281,"url":"https://github.com/workable/diamorphosis","last_synced_at":"2026-03-12T11:04:54.595Z","repository":{"id":52163513,"uuid":"79821744","full_name":"Workable/diamorphosis","owner":"Workable","description":"Configure Nodejs apps with env vars.","archived":false,"fork":false,"pushed_at":"2025-02-13T08:10:48.000Z","size":469,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-08-09T04:37:03.055Z","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/Workable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-23T16:17:20.000Z","updated_at":"2025-02-13T08:10:32.000Z","dependencies_parsed_at":"2025-02-11T12:32:17.137Z","dependency_job_id":"e82b66e2-0a08-4748-9212-dde302b84896","html_url":"https://github.com/Workable/diamorphosis","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/Workable/diamorphosis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2Fdiamorphosis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2Fdiamorphosis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2Fdiamorphosis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2Fdiamorphosis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Workable","download_url":"https://codeload.github.com/Workable/diamorphosis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2Fdiamorphosis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270469738,"owners_count":24589243,"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","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"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-11-19T12:26:56.669Z","updated_at":"2026-03-12T11:04:54.540Z","avatar_url":"https://github.com/Workable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diamorphosis\n\nUse\n  - JSON file(s)\n  - .env file for development\n  - ENV vars\n\nto configure your application for different environments (NODE_ENV).\nSupports defaults. Supports nested values.\n\n## Installation\n\n```js\n$ npm install diamorphosis\n```\n\n## Features\n\n- Use JSON or JS files to configure your application for different NODE_ENV values (production, dev, etc...)\n\n```javascript\n// file: config/config.js\n{\n  my_var_a : \"some value\",\n  myVarB: \"some value\"\n}\n```\n\n```javascript\n// file: config/env/production.json\n{\n  \"nested\":{\n    \"my_var_a\" : \"some production value\",\n    \"myVarB\": \"some production value\"\n  }\n}\n```\n\nTo enable the production configuration set NODE_ENV=production\n\n\n\n- Overwrite your application's config by using ENV variables and restarting the app. Supports scalar and array values.\n\n```\nexport NESTED_MY_VAR_A=someScalarValue\nexport NESTED_MY_VAR_B=this,var,is,an,array,of,values // NESTED_MYVARB is also supported\nexport NESTED_BOOLEAN=true\n```\n\n- Use .env file for development\n```\n  NESTED_MY_VAR_A=someValue\n```\n\n## Example\n\n```javascript\n// file: config/config.js\n// var names should be snakecase (a_var_example) in order to be able to overwrite them correctly using env vars.\nmodule.exports =\n{\n  varOne: '1_dev_',\n  nestedExample: {\n    varTwo: '2_dev_'\n  }\n}\n```\n\n```javascript\n// file: config/evn/production.json\n{\n  \"varOne\": '1_prod',\n  \"nestedExample\": {\n    \"varTwo\": \"2_prod\"\n  }\n}\n```\n\n```javascript\n// file: config/evn/other.json\n{\n  \"varOne\": '1_other',\n  \"nestedExample\": {\n    \"varTwo\": \"2_other\"\n  }\n}\n```\n\n```javascript\n// file: app.js\nconst diamorphosis = require('diamorphosis');\ndiamorphosis({ // these are the default values\n  configFolder: './config',\n  configPath: './config/config.js',\n  envFolder: './config/env',\n  loadDotEnv: ['development'] // will only load .env if NODE_ENV=development\n})\n\n```\n\n```js\n// file: myFile.js\nconst config = require('./config/config');\nconsole.log(var_one:', config.var_one);\nconsole.log(var_two:', config.nested_example.varTwo);\n\n// Env vars can overwrite the config values. The app will need a restart to load the new values:\n// export VAR_ONE=\"some other value for var one\"\n// export NESTED_EXAMPLE_VAR_TWO=\"some other value for var two\"\n```\n\n```md\n# file .env\n\nVAR_ONE=value\n```\n\n## Supported types\n\n- number\n- boolean\n- string\n\n## es6 support\n\nConfig.js can use the es6 export default eg:\n\n```js\nexport default {\n  varOne: '1_dev_',\n  nestedExample: {\n    varTwo: '2_dev_'\n  }\n}\n```\n\nThis is especially useful if you are using diamorphosis with typescript.\n\nNote that env files can have .json or .js extension\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkable%2Fdiamorphosis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkable%2Fdiamorphosis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkable%2Fdiamorphosis/lists"}