{"id":22740716,"url":"https://github.com/rjyo/yaml-config-node","last_synced_at":"2025-04-14T06:03:55.620Z","repository":{"id":140234386,"uuid":"1852601","full_name":"rjyo/yaml-config-node","owner":"rjyo","description":"Manage your node.js app configuration based on NODE_ENV, all configuration defined in yaml","archived":false,"fork":false,"pushed_at":"2013-12-24T14:27:51.000Z","size":143,"stargazers_count":40,"open_issues_count":6,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T06:02:02.947Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rjyo.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-06-06T01:47:57.000Z","updated_at":"2020-11-10T01:28:22.000Z","dependencies_parsed_at":"2023-03-13T10:44:04.017Z","dependency_job_id":null,"html_url":"https://github.com/rjyo/yaml-config-node","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjyo%2Fyaml-config-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjyo%2Fyaml-config-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjyo%2Fyaml-config-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjyo%2Fyaml-config-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjyo","download_url":"https://codeload.github.com/rjyo/yaml-config-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830397,"owners_count":21168272,"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-12-10T23:10:25.710Z","updated_at":"2025-04-14T06:03:55.548Z","avatar_url":"https://github.com/rjyo.png","language":"JavaScript","readme":"# yaml-config\n\nManage your configuration based on NODE_ENV, all configuration defined with yaml. Shared configuration can be put under `default` key, different settings under each enviroment name.\n\n## Installation\n\n    $ npm install yaml-config\n\n## Usage\n\nIn the setting file at `config/app.yaml`\n\n```yaml\ndefault:\n  redis:\n    port: 6379                # redis server port\n    host: '127.0.0.1'         # redis host\n    password: ''              # to use with AUTH\n    db: 1                     # the test db\n    options: {}\ntest:\n  redis:\n    db: 12\nproduction:\n  redis:\n    db: 0\n  new_prop:\n    hello: 'world'\n```\n\nIn your source code\n\n```javascript\nvar config = require('yaml-config');\nvar settings = config.readConfig('./config/app.yaml'); // path from your app root without slash\nconsole.log(settings.redis.db); // if NODE_ENV is development, prints 1\n```\n\nThe `readConfig()` function takes a second parameter as enviroment name, for example\n\n```javascript\nvar settings = config.readConfig('./config/app.yaml', 'test');\nconsole.log(settings.redis.db); // prints 12\n```\nThe `updateConfig()` function will take current settings and save them back to the configuration file\n```javascript\nvar settings = config.readConfig('./config/app.yaml', 'production');\nconsole.log(settings.redis.db); // prints 12\nsettings.redis.db = 10;\nupdateConfig(settings, './config/app.yaml', 'production'); //Save 10 to redis.db of the 'production' section\nupdateConfig({},'./config/app.yaml', 'production'); //Will remove the entire 'production' section\n```\n\nIf the settings are used in multiple files, you may want to put the loading code in a seperate file and require it when used, so that config file will be loaded only once.\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011 Rakuraku Jyo \u0026lt;jyo.rakuraku@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjyo%2Fyaml-config-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjyo%2Fyaml-config-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjyo%2Fyaml-config-node/lists"}