{"id":17667722,"url":"https://github.com/jeromemacias/node-rob-config","last_synced_at":"2025-05-06T20:44:46.779Z","repository":{"id":10796931,"uuid":"67035271","full_name":"jeromemacias/node-rob-config","owner":"jeromemacias","description":"Robust configuration package for nodejs, built on top of convict","archived":false,"fork":false,"pushed_at":"2024-01-25T15:15:51.000Z","size":2032,"stargazers_count":11,"open_issues_count":17,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T03:40:06.211Z","etag":null,"topics":["config","configuration","convict","environment-variables","nodejs","robust","schema","schema-description","validation"],"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/jeromemacias.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":"2016-08-31T12:28:20.000Z","updated_at":"2022-03-16T10:07:05.000Z","dependencies_parsed_at":"2023-01-13T16:09:39.530Z","dependency_job_id":null,"html_url":"https://github.com/jeromemacias/node-rob-config","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromemacias%2Fnode-rob-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromemacias%2Fnode-rob-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromemacias%2Fnode-rob-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromemacias%2Fnode-rob-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeromemacias","download_url":"https://codeload.github.com/jeromemacias/node-rob-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769107,"owners_count":21801373,"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","convict","environment-variables","nodejs","robust","schema","schema-description","validation"],"created_at":"2024-10-23T22:22:55.633Z","updated_at":"2025-05-06T20:44:46.740Z","avatar_url":"https://github.com/jeromemacias.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rob-config\n\n[![NPM version](http://img.shields.io/npm/v/rob-config.svg)](https://www.npmjs.org/package/rob-config)\n![node-current](https://img.shields.io/node/v/rob-config)\n[![Build Status](https://travis-ci.org/jeromemacias/node-rob-config.svg?branch=master)](https://travis-ci.org/jeromemacias/node-rob-config)\n\nRobust configuration module for nodejs, built on top of [`convict`](https://github.com/mozilla/node-convict).\n\n## Installation\n\n`npm install rob-config --save`\n\n## Why another config package?\n\n[`config`](https://github.com/lorenwest/node-config) is a very simple and powerfull config package but it lacks from schema and validation.\n\n[`convict`](https://github.com/mozilla/node-convict) is not simple to use, but way more robust and overridable.\n\nSo I wanted something:\n\n-   Easy to use like `config`\n-   With schema and documentation like `convict`\n-   With possibility to override with env variable or command line argument like `convict`\n-   With a command to validate config for dev AND before deployment to production\n-   With a command to see the builded config depends on env and default value (easier to debug)\n\nHere it is and it's very easy to migrate from `config` or `convict`.\n\n## Usage\n\nDefine a config schema, simple object.\n\nSee https://github.com/mozilla/node-convict#the-schema for documentation about schema definition.\n\nFor example: `config/schema.js`\n\n```js\nmodule.exports = {\n    env: {\n        doc: 'The applicaton environment.',\n        format: ['production', 'staging', 'integration', 'development', 'test'],\n        default: 'development',\n        env: 'NODE_ENV',\n    },\n    api: {\n        port: {\n            doc: 'The API port',\n            format: 'port',\n            default: 3000,\n        },\n        timeout: {\n            doc: 'The API timeout',\n            format: 'nat',\n            default: 60 * 1000, // 1 minutes\n        },\n    },\n};\n```\n\nThen, define the first config file.\n\nFor example: `config/development.js`\n\n```js\nmodule.exports = {\n    api: {\n        port: 3001, // test with \"nothing\" value to see validation error\n    },\n};\n```\n\nYou can, optionnaly, define a `config/formats.js` to add one or more custom format to convict.\n\nSee https://github.com/mozilla/node-convict#custom-format-checking for documentation about custom formats.\n\n`convict.addFormats()` will be call under the hood.\n\nFor exemple: `config/formats.js`\n\n```js\nmodule.exports = {\n    'float-percent': {\n        validate: function (val) {\n            if (val !== 0 \u0026\u0026 (!val || val \u003e 1 || val \u003c 0)) {\n                throw new Error('must be a float between 0 and 1, inclusive');\n            }\n        },\n        coerce: function (val) {\n            return parseFloat(val, 10);\n        },\n    },\n};\n```\n\n### Display your builded configuration\n\nRun `./node_modules/.bin/rob-config show`:\n\n![Display final configuration](example/screenshot/show.png?raw=true)\n\n### Validate your configuration against schema\n\nRun `./node_modules/.bin/rob-config validate`:\n\n![Validate configuration ok](example/screenshot/validate-ok.png?raw=true)\n\nIn case of error:\n\n![Validate configuration error](example/screenshot/validate-error.png?raw=true)\n\n### Display the schema description\n\nRun `./node_modules/.bin/rob-config describe`:\n\n![Schema description](example/screenshot/describe.png?raw=true)\n\n### Use it in your project\n\n```js\nconst config = require('rob-config');\n\nconsole.log(config.get('api.port'));\n```\n\n### Change config dir\n\nYou can set env variable `ROB_CONFIG_DIR` with the relative path of your project configuration directory.\n\n## Versioning\n\nTo keep better organization of releases we follow the [Semantic Versioning 2.0.0](http://semver.org/) guidelines.\n\nSee [Releases](https://github.com/jeromemacias/node-rob-config/releases) for detailed changelog.\n\n## License\n\n[MIT License](/LICENSE) © [Jérôme Macias](https://github.com/jeromemacias)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromemacias%2Fnode-rob-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeromemacias%2Fnode-rob-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromemacias%2Fnode-rob-config/lists"}