{"id":17664429,"url":"https://github.com/tilfin/konfig-yaml","last_synced_at":"2025-05-07T23:38:43.519Z","repository":{"id":143883215,"uuid":"82641550","full_name":"tilfin/konfig-yaml","owner":"tilfin","description":"Loader of YAML configuration for each execution enviroments","archived":false,"fork":false,"pushed_at":"2019-07-08T09:54:00.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T23:38:33.809Z","etag":null,"topics":["config","configuration","nodejs","npm","yaml"],"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/tilfin.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-21T05:51:15.000Z","updated_at":"2020-11-10T02:02:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"d726aab7-427f-46b1-9ba1-0ba9013f1d7e","html_url":"https://github.com/tilfin/konfig-yaml","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tilfin","download_url":"https://codeload.github.com/tilfin/konfig-yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973607,"owners_count":21834104,"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":["config","configuration","nodejs","npm","yaml"],"created_at":"2024-10-23T20:05:24.727Z","updated_at":"2025-05-07T23:38:43.500Z","avatar_url":"https://github.com/tilfin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"konfig-yaml\n===========\n\n[![NPM Version][npm-image]][npm-url]\n[![Build Status](https://travis-ci.org/tilfin/konfig-yaml.svg?branch=master)](https://travis-ci.org/tilfin/konfig-yaml)\n[![Code Climate](https://codeclimate.com/github/tilfin/konfig-yaml/badges/gpa.svg)](https://codeclimate.com/github/tilfin/konfig-yaml)\n[![Test Coverage](https://codeclimate.com/github/tilfin/konfig-yaml/badges/coverage.svg)](https://codeclimate.com/github/tilfin/konfig-yaml/coverage)\n\nThe loader of yaml base configuration for each run enviroments like [settingslogic](https://github.com/settingslogic/settingslogic).\n\n- Expand environment variables (ex. `users-${NODE_ENV}`)\n    - If an environment variable is not set, it is to be emtpy string.\n    - If `${DB_USER:-user}` or `${DB_USER:user}` is defined, `user` is expanded unless DB_USER does not exists.\n- Deep merge the environment settings and default settings (except array items)\n- Node.js 6.10 or later\n- The [gem library](https://github.com/tilfin/konfig-yaml-rb) also exists for Ruby.\n\n## Install\n\n```\n$ npm i konfig-yaml\n```\n\n\n## How to Use\n\n```\nconst konfig = require('konfig-yaml');\n\nconfig = konfig(\u003cname\u003e, [opts]);\n```\n\n* `name` specifys the name of `config/\u003cname\u003e.yml` ( default `app` )\n* `opts`\n  * `path` config directory path resolved from the process current one ( default **NODE_CONFIG_DIR** value or `config` )\n  * `env` Run environment ( default **NODE_ENV** value or `development` )\n  * `useCache` whether using cache ( default `true` )\n\n#### Clear cache\n\n```\nkonfig.clear();\n```\n\n\n## Example\n\n### Setup\n\n#### config/app.yml\n\n```\ndefault:\n  port: 8080\n  logger:\n    level: info\n  db:\n    name: ${BRAND}-app-${NODE_ENV}\n    user: user\n    pass: pass\n\nproduction:\n  port: 1080\n  logger:\n    level: error\n  db:\n    pass: Password\n```\n\n#### main.js\n\n```\nconst konfig = require('konfig-yaml');\nconst config = konfig();\n\nconsole.log(config.port);\nconsole.log(config.logger.level);\nconsole.log(config.db.user);\nconsole.log(config.db.name);\nconsole.log(config.db.password);\n```\n\n### Run\n\n#### In development\n\n```\n$ NODE_ENV=development BRAND=normal node main.js\n8080\ninfo\nnormal-app-development\nuser\npass\n```\n\n#### In production\n\n```\n$ NODE_ENV=production BRAND=awesome node main.js\n1080\nerror\nawesome-app-production\nuser\nPassword\n```\n\n\n## License\n\n  [MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/konfig-yaml.svg\n[npm-url]: https://npmjs.org/package/konfig-yaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilfin%2Fkonfig-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftilfin%2Fkonfig-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilfin%2Fkonfig-yaml/lists"}