{"id":19232676,"url":"https://github.com/makeomatic/ms-conf","last_synced_at":"2025-07-28T01:34:44.225Z","repository":{"id":2163739,"uuid":"45838268","full_name":"makeomatic/ms-conf","owner":"makeomatic","description":"Wrapper over dotenv and nconf module for one line configuration loading","archived":false,"fork":false,"pushed_at":"2024-04-04T15:47:01.000Z","size":769,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-20T17:19:56.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/makeomatic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-11-09T13:03:14.000Z","updated_at":"2023-05-08T16:28:10.000Z","dependencies_parsed_at":"2024-06-19T09:57:03.920Z","dependency_job_id":"74513a2a-1c37-4563-981c-85235d132dac","html_url":"https://github.com/makeomatic/ms-conf","commit_stats":null,"previous_names":["makeomatic/ms-amqp-conf"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/makeomatic/ms-conf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-conf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-conf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-conf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-conf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makeomatic","download_url":"https://codeload.github.com/makeomatic/ms-conf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-conf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267451149,"owners_count":24089293,"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-07-27T02:00:11.917Z","response_time":82,"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-09T16:07:09.249Z","updated_at":"2025-07-28T01:34:44.141Z","avatar_url":"https://github.com/makeomatic.png","language":"TypeScript","readme":"# Configuration loading module\n\nCombines confidence, dotenv, nconf and processes env configuration into camelcase;\nEach value is JSON parsed first if it is possible, therefore you can pass arrays/objects and boolean params through env\n\n## Installation\n\n`npm i ms-conf` or any other manager\n\n## Configuration\n\nAccepts following configuration params, which can be passed through `.env` or process.env\n\n1. `DOTENV_NOT_SILENT` - if present, warnings from dotenv wont be supressed\n2. `DOTENV_ENCODING` - defaults to 'utf-8'\n3. `DOTENV_FILE_PATH` - if .env file isn't located in the root of your module, you can pass path here\n4. `NCONF_SEPARATOR` - defaults to `__`\n5. `NCONF_MATCH` - only envs, matched by this would be returned through configuration\n6. `NCONF_MATCH_OPTS` - opts for regexp constructed from `NCONF_MATCH`\n7. `NCONF_WHITELIST` - stringified JSON array of variebles that should be parsed into final configuration\n8. `NCONF_FILE_PATH` - external JSON configuration file that will be used to provide variables\n9. `NCONF_NAMESPACE` - **MUST** be specified, as it will return configuration relative to this namespace\n10. `NCONF_NO_CAMELCASE` - if present, keys will not be camelCased\n\n## Usage\n\n`.env` file:\n\n```\nNCONF_NAMESPACE=MS_CONF\nNCONF_MATCH=^MS_CONF\nNCONF_MATCH_OPTS=i\nMS_CONF__AMQP__HOSTS=[\"127.0.0.1\"]\nMS_CONF__AMQP__SSL=true\nMS_CONF__AMQP__STRING_TRUE='\"true\"'\nNCONF_FILE_PATH=[\"/etc/app-configs\",\"/etc/nice-config.js\",\"/opt/app/bundle.json\"]\n```\n\n```js\n// ESM\nimport { Store } from 'ms-conf';\n// CJS\nconst { Store } = require('ms-conf');\n\n// get basic configuration\nconst store = new Store()\nconst config = store.get('/');\n// config would equal\n// {\n//   amqp: {\n//     hosts: ['127.0.0.1'],\n//     ssl: true,\n//     stringTrue: 'true'\n//   }\n// }\n\nstore.get('/amqp') // will return inner object and so on\nstore.get('/amqp/hosts') // ['127.0.0.1']\n```\n\n## Hot Reload\n\n```js\nstore.enableReload();\n// send SIGUSR1 or SIGUSR2 signal to process to reload configuration\n\nstore.disableReload();\n// wont listen for SIGUSR1 or SIGUSR2 events any longer\n```\n\n## Utilities\n\n1. Load file path\n\n```js\n// CJS\nconst { globFiles } = require('ms-conf');\n// ESM\nimport { globFiles } from 'ms-conf';\n\n// generates config for the passed files bypassing public API\nconst config = globFiles(\n  undefined, // prependFile: string | undefined,\n  ['/path/to/configs', '/path/to/config/direct.js', '/path/to/conf.json'], // fileList: string | string[]\n  {}, // config: baseConfig\n  true, // throw error in case of file processing issues\n);\n```\n\n2. setDefaultOpts\n\n```js\n// define default options\nconst store = new Store({ defaultOpts: { env: process.env.NODE_ENV } })\n\n// change default opts in runtime\nstore.opts.defaultOpts = { env: process.env.NODE_ENV }\n```\n\n3. prependDefaultConfiguration\n\nPass absolute filepath, which would be prepended. Useful to pass a directory with bundled default config\n\n```js\nstore.prependDefaultConfiguration(filePath);\n```\n\n4. crash when configuration files can't be loaded\n\nin 8+ behavior changes and malformed configuration files are not ignored anymore.\nTo disable this set crashOnError option to false`\n\n```js\nconst { Store } = require('ms-conf');\n\nconst store = new Store({ crashOnError: false })\nconf.prependDefaultConfiguration(['/path/to/config.json']);\nconf.get('/path') // wont throw errors on malformed files, but will write into stderr notifying of the error\n```\n\nFor a more detailed example - see tests\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakeomatic%2Fms-conf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakeomatic%2Fms-conf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakeomatic%2Fms-conf/lists"}