{"id":13403121,"url":"https://github.com/indexzero/nconf","last_synced_at":"2026-03-11T08:03:49.648Z","repository":{"id":748033,"uuid":"1549544","full_name":"indexzero/nconf","owner":"indexzero","description":"Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.","archived":false,"fork":false,"pushed_at":"2026-02-07T01:43:46.000Z","size":922,"stargazers_count":3864,"open_issues_count":112,"forks_count":258,"subscribers_count":69,"default_branch":"master","last_synced_at":"2026-03-09T08:12:10.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/indexzero/nconf","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/indexzero.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2011-03-31T04:55:37.000Z","updated_at":"2026-02-26T02:25:22.000Z","dependencies_parsed_at":"2023-07-05T19:02:32.488Z","dependency_job_id":"6d4f0793-c1e9-4774-8cee-f0d3b8f2b945","html_url":"https://github.com/indexzero/nconf","commit_stats":{"total_commits":341,"total_committers":73,"mean_commits":4.671232876712328,"dds":0.5777126099706744,"last_synced_commit":"ce212b2f1dbf96cee001b5f621979c564638f0e7"},"previous_names":["flatiron/nconf"],"tags_count":102,"template":false,"template_full_name":null,"purl":"pkg:github/indexzero/nconf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fnconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fnconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fnconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fnconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indexzero","download_url":"https://codeload.github.com/indexzero/nconf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fnconf/sbom","scorecard":{"id":402736,"data":{"date":"2025-08-11","repo":{"name":"github.com/indexzero/nconf","commit":"87e07262d9425a80d57990e2a9cbdaebcadf2e05"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":4,"reason":"Found 8/19 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/node.js.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/indexzero/nconf/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/indexzero/nconf/node.js.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/node.js.yml:29","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T20:27:35.606Z","repository_id":748033,"created_at":"2025-08-18T20:27:35.606Z","updated_at":"2025-08-18T20:27:35.606Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30375545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-07-30T19:01:25.701Z","updated_at":"2026-03-11T08:03:49.630Z","avatar_url":"https://github.com/indexzero.png","language":"JavaScript","readme":"# nconf\n\n[![Version npm](https://img.shields.io/npm/v/nconf.svg?style=flat-square)](https://www.npmjs.com/package/nconf)[![npm Downloads](https://img.shields.io/npm/dm/nconf.svg?style=flat-square)](https://www.npmjs.com/package/nconf)[![Build Status](https://img.shields.io/travis/indexzero/nconf/master.svg?style=flat-square)](https://travis-ci.org/indexzero/nconf)[![Coverage](https://img.shields.io/coveralls/indexzero/nconf.svg?style=flat-square)](https://coveralls.io/github/indexzero/nconf)[![Dependencies](https://img.shields.io/david/indexzero/nconf.svg?style=flat-square)](https://david-dm.org/indexzero/nconf)\n\nHierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.\n\n## Example\nUsing nconf is easy; it is designed to be a simple key-value store with support for both local and remote storage. Keys are namespaced and delimited by `:`. Let's dive right into sample usage:\n\n``` js\n  // sample.js\n  var nconf = require('nconf');\n\n  //\n  // Setup nconf to use (in-order):\n  //   1. Command-line arguments\n  //   2. Environment variables\n  //   3. A file located at 'path/to/config.json'\n  //\n  nconf.argv()\n   .env()\n   .file({ file: 'path/to/config.json' });\n\n  //\n  // Set a few variables on `nconf`.\n  //\n  nconf.set('database:host', '127.0.0.1');\n  nconf.set('database:port', 5984);\n\n  //\n  // Get the entire database object from nconf. This will output\n  // { host: '127.0.0.1', port: 5984 }\n  //\n  console.log('foo: ' + nconf.get('foo'));\n  console.log('NODE_ENV: ' + nconf.get('NODE_ENV'));\n  console.log('database: ' + nconf.get('database'));\n\n  //\n  // Save the configuration object to disk\n  //\n  nconf.save(function (err) {\n    require('fs').readFile('path/to/your/config.json', function (err, data) {\n      console.dir(JSON.parse(data.toString()))\n    });\n  });\n```\n\nIf you run the below script:\n\n``` bash\n  $ NODE_ENV=production node sample.js --foo bar\n```\n\nThe output will be:\n\n```\n  foo: bar\n  NODE_ENV: production\n  database: { host: '127.0.0.1', port: 5984 }\n```\n\n## Hierarchical configuration\n\nConfiguration management can get complicated very quickly for even trivial applications running in production. `nconf` addresses this problem by enabling you to setup a hierarchy for different sources of configuration with no defaults. **The order in which you attach these configuration sources determines their priority in the hierarchy.** Let's take a look at the options available to you\n\n  1. **nconf.argv(options)** Loads `process.argv` using yargs. If `options` is supplied it is passed along to yargs.\n  2. **nconf.env(options)** Loads `process.env` into the hierarchy.\n  3. **nconf.file(options)** Loads the configuration data at options.file into the hierarchy.\n  4. **nconf.defaults(options)** Loads the data in options.store into the hierarchy.\n  5. **nconf.overrides(options)** Loads the data in options.store into the hierarchy.\n\nA sane default for this could be:\n\n``` js\n  var nconf = require('nconf');\n\n  //\n  // 1. any overrides\n  //\n  nconf.overrides({\n    'always': 'be this value'\n  });\n\n  //\n  // 2. `process.env`\n  // 3. `process.argv`\n  //\n  nconf.env().argv();\n\n  //\n  // 4. Values in `config.json`\n  //\n  nconf.file('/path/to/config.json');\n\n  //\n  // Or with a custom name\n  // Note: A custom key must be supplied for hierarchy to work if multiple files are used.\n  //\n  nconf.file('custom', '/path/to/config.json');\n\n  //\n  // Or searching from a base directory.\n  // Note: `name` is optional.\n  //\n  nconf.file(name, {\n    file: 'config.json',\n    dir: 'search/from/here',\n    search: true\n  });\n\n  //\n  // 5. Any default values\n  //\n  nconf.defaults({\n    'if nothing else': 'use this value'\n  });\n```\n\n## API Documentation\n\nThe top-level of `nconf` is an instance of the `nconf.Provider` abstracts this all for you into a simple API.\n\n### nconf.add(name, options)\nAdds a new store with the specified `name` and `options`. If `options.type` is not set, then `name` will be used instead:\n\n``` js\n  nconf.add('supplied', { type: 'literal', store: { 'some': 'config' } });\n  nconf.add('user', { type: 'file', file: '/path/to/userconf.json' });\n  nconf.add('global', { type: 'file', file: '/path/to/globalconf.json' });\n```\n\n### nconf.any(names, callback)\nGiven a set of key names, gets the value of the first key found to be truthy. The key names can be given as separate arguments\nor as an array. If the last argument is a function, it will be called with the result; otherwise, the value is returned.\n\n``` js\n  //\n  // Get one of 'NODEJS_PORT' and 'PORT' as a return value\n  //\n  var port = nconf.any('NODEJS_PORT', 'PORT');\n\n  //\n  // Get one of 'NODEJS_IP' and 'IPADDRESS' using a callback\n  //\n  nconf.any(['NODEJS_IP', 'IPADDRESS'], function(err, value) {\n    console.log('Connect to IP address ' + value);\n  });\n```\n\n### nconf.use(name, options)\nSimilar to `nconf.add`, except that it can replace an existing store if new options are provided\n\n``` js\n  //\n  // Load a file store onto nconf with the specified settings\n  //\n  nconf.use('file', { file: '/path/to/some/config-file.json' });\n\n  //\n  // Replace the file store with new settings\n  //\n  nconf.use('file', { file: 'path/to/a-new/config-file.json' });\n```\n\n### nconf.remove(name)\nRemoves the store with the specified `name.` The configuration stored at that level will no longer be used for lookup(s).\n\n``` js\n  nconf.remove('file');\n```\n\n### nconf.required(keys)\nDeclares a set of string keys to be mandatory, and throw an error if any are missing.\n\n``` js\n  nconf.defaults({\n    keya: 'a',\n  });\n\n  nconf.required(['keya', 'keyb']);\n  // Error: Missing required keys: keyb\n```\nYou can also chain `.required()` calls when needed. for example when a configuration depends on another configuration store\n\n```js\nconfig\n  .argv()\n  .env()\n  .required([ 'STAGE']) //here you should have STAGE otherwise throw an error\n  .file( 'stage', path.resolve( 'configs', 'stages', config.get( 'STAGE' ) + '.json' ) )\n  .required([ 'OAUTH:redirectURL']) // here you should have OAUTH:redirectURL, otherwise throw an error\n  .file( 'oauth', path.resolve( 'configs', 'oauth', config.get( 'OAUTH:MODE' ) + '.json' ) )\n  .file( 'app', path.resolve( 'configs', 'app.json' ) )\n  .required([ 'LOGS_MODE']) // here you should haveLOGS_MODE, otherwise throw an error\n  .add( 'logs', {\n    type: 'literal',\n    store: require( path.resolve( 'configs', 'logs', config.get( 'LOGS_MODE' ) + '.js') )\n  } )\n  .defaults( defaults );\n```\n\n## Storage Engines\n\n### Memory\nA simple in-memory storage engine that stores a nested JSON representation of the configuration. To use this engine, just call `.use()` with the appropriate arguments. All calls to `.get()`, `.set()`, `.clear()`, `.reset()` methods are synchronous since we are only dealing with an in-memory object.\n\nAll built-in storage engines inherit from the Memory store.\n\nBasic usage:\n\n``` js\n  nconf.use('memory');\n```\n\n#### Options\n\nThe options defined below apply to all storage engines that inherit from Memory.\n\n##### `accessSeparator: string` (default: `':'`)\nDefines the separator used to get or set data using the `get()` and `set()` methods. Even if this is changed, the default \"colon\" separator will be available unless explicitly disabled (see `disableDefaultAccessSeparator`).\n\n##### `inputSeparator: string` (default: `'__'`)\nThis option is used by the `argv` and `env` storage engines when loading values. Since most systems only allow dashes, underscores, and alphanumeric characters in environment variables and command line arguments, the `inputSeparator` provides a mechanism for loading hierarchical values from these sources.\n\n##### `disableDefaultAccessSeparator: {true|false}` (default: `false`)\nDisables the default access separator of `':'`, which is always available otherwise. This is mainly used to preserve legacy behavior. It can also be used to set keys that contain the default separator (e.g. `{ 'some:long:key' : 'some value' }`).\n\n### Argv\nResponsible for loading the values parsed from `process.argv` by `yargs` into the configuration hierarchy. See the [yargs option docs](https://github.com/bcoe/yargs#optionskey-opt) for more on the option format.\n\n#### Options\n\n##### `parseValues: {true|false}` (default: `false`)\nAttempt to parse well-known values (e.g. 'false', 'true', 'null', 'undefined', '3', '5.1' and JSON values)\ninto their proper types. If a value cannot be parsed, it will remain a string.\n\n##### `transform: function(obj)`\nPass each key/value pair to the specified function for transformation.\n\nThe input `obj` contains two properties passed in the following format:\n``` js\n{\n  key: '\u003cstring\u003e',\n  value: '\u003cstring\u003e'\n}\n```\n\nThe transformation function may alter both the key and the value.\n\nThe function may return either an object in the same format as the input or a value that evaluates to false.\nIf the return value is falsey, the entry will be dropped from the store, otherwise it will replace the original key/value.\n\n*Note: If the return value doesn't adhere to the above rules, an exception will be thrown.*\n\n#### Examples\n\n``` js\n  //\n  // Can optionally also be an object literal to pass to `yargs`.\n  //\n  nconf.argv({\n    \"x\": {\n      alias: 'example',\n      describe: 'Example description for usage generation',\n      demand: true,\n      default: 'some-value',\n      parseValues: true,\n      transform: function(obj) {\n        if (obj.key === 'foo') {\n          obj.value = 'baz';\n        }\n        return obj;\n      }\n    }\n  });\n```\n\nIt's also possible to pass a configured yargs instance\n\n``` js\n  nconf.argv(require('yargs')\n    .version('1.2.3')\n    .usage('My usage definition')\n    .strict()\n    .options({\n      \"x\": {\n        alias: 'example',\n        describe: 'Example description for usage generation',\n        demand: true,\n        default: 'some-value'\n      }\n    }));\n```\n\n### Env\nResponsible for loading the values parsed from `process.env` into the configuration hierarchy.\nBy default, the env variables values are loaded into the configuration as strings.\n\n#### Options\n\n##### `lowerCase: {true|false}` (default: `false`)\nConvert all input keys to lower case. Values are not modified.\n\nIf this option is enabled, all calls to `nconf.get()` must pass in a lowercase string (e.g. `nconf.get('port')`)\n\n##### `parseValues: {true|false}` (default: `false`)\nAttempt to parse well-known values (e.g. 'false', 'true', 'null', 'undefined', '3', '5.1' and JSON values)\ninto their proper types. If a value cannot be parsed, it will remain a string.\n\n##### `transform: function(obj)`\nPass each key/value pair to the specified function for transformation.\n\nThe input `obj` contains two properties passed in the following format:\n``` js\n{\n  key: '\u003cstring\u003e',\n  value: '\u003cstring\u003e'\n}\n```\n\nThe transformation function may alter both the key and the value.\n\nThe function may return either an object in the same format as the input or a value that evaluates to false.\nIf the return value is falsey, the entry will be dropped from the store, otherwise it will replace the original key/value.\n\n*Note: If the return value doesn't adhere to the above rules, an exception will be thrown.*\n\n#### `readOnly: {true|false}` (default: `true`)\nAllow values in the env store to be updated in the future. The default is to not allow items in the env store to be updated.\n\n#### Examples\n\n``` js\n  //\n  // Can optionally also be an Array of values to limit process.env to.\n  //\n  nconf.env(['only', 'load', 'these', 'values', 'from', 'process.env']);\n\n  //\n  // Can also specify an input separator for nested keys\n  //\n  nconf.env('__');\n  // Get the value of the env variable 'database__host'\n  var dbHost = nconf.get('database:host');\n\n  //\n  // Can also lowerCase keys.\n  // Especially handy when dealing with environment variables which are usually\n  // uppercased while argv are lowercased.\n  //\n\n  // Given an environment variable PORT=3001\n  nconf.env();\n  var port = nconf.get('port') // undefined\n\n  nconf.env({ lowerCase: true });\n  var port = nconf.get('port') // 3001\n\n  //\n  // Or use all options\n  //\n  nconf.env({\n    inputSeparator: '__',\n    match: /^whatever_matches_this_will_be_whitelisted/\n    whitelist: ['database__host', 'only', 'load', 'these', 'values', 'if', 'whatever_doesnt_match_but_is_whitelisted_gets_loaded_too'],\n    lowerCase: true,\n    parseValues: true,\n    transform: function(obj) {\n      if (obj.key === 'foo') {\n        obj.value = 'baz';\n      }\n      return obj;\n    }\n  });\n  var dbHost = nconf.get('database:host');\n```\n\n### Literal\nLoads a given object literal into the configuration hierarchy. Both `nconf.defaults()` and `nconf.overrides()` use the Literal store.\n\n``` js\n  nconf.defaults({\n    'some': 'default value'\n  });\n```\n\n### File\nBased on the Memory store, but provides additional methods `.save()` and `.load()` which allow you to read your configuration to and from file. As with the Memory store, all method calls are synchronous with the exception of `.save()` and `.load()` which take callback functions.\n\nIt is important to note that setting keys in the File engine will not be persisted to disk until a call to `.save()` is made. Note a custom key must be supplied as the first parameter for hierarchy to work if multiple files are used.\n\n``` js\n  nconf.file('path/to/your/config.json');\n  // add multiple files, hierarchically. notice the unique key for each file\n  nconf.file('user', 'path/to/your/user.json');\n  nconf.file('global', 'path/to/your/global.json');\n```\n\nThe file store is also extensible for multiple file formats, defaulting to `JSON`. To use a custom format, simply pass a format object to the `.use()` method. This object must have `.parse()` and `.stringify()` methods just like the native `JSON` object.\n\nIf the file does not exist at the provided path, the store will simply be empty.\n\n#### Encrypting file contents\n\nAs of `nconf@0.8.0` it is now possible to encrypt and decrypt file contents using the `secure` option:\n\n``` js\nnconf.file('secure-file', {\n  file: 'path/to/secure-file.json',\n  secure: {\n    secret: 'super-secretzzz-keyzz',\n    alg: 'aes-256-ctr'\n  }\n})\n```\n\nThis will encrypt each key using [`crypto.createCipheriv`](https://nodejs.org/api/crypto.html#crypto_crypto_createcipheriv_algorithm_key_iv_options), defaulting to `aes-256-ctr`. The encrypted file contents will look like this:\n\n``` js\n{\n  \"config-key-name\": {\n    \"alg\": \"aes-256-ctr\", // cipher used\n    \"value\": \"af07fbcf\",   // encrypted contents\n    \"iv\": \"49e7803a2a5ef98c7a51a8902b76dd10\" // initialization vector\n  },\n  \"another-config-key\": {\n    \"alg\": \"aes-256-ctr\",   // cipher used\n    \"value\": \"e310f6d94f13\", // encrypted contents\n    \"iv\": \"b654e01aed262f37d0acf200be193985\" // initialization vector\n  },\n}\n```\n\n### Redis\nThere is a separate Redis-based store available through [nconf-redis][0]. To install and use this store simply:\n\n``` bash\n  $ npm install nconf\n  $ npm install nconf-redis\n```\n\nOnce installing both `nconf` and `nconf-redis`, you must require both modules to use the Redis store:\n\n``` js\n  var nconf = require('nconf');\n\n  //\n  // Requiring `nconf-redis` will extend the `nconf`\n  // module.\n  //\n  require('nconf-redis');\n\n  nconf.use('redis', { host: 'localhost', port: 6379, ttl: 60 * 60 * 1000 });\n```\n\n## Installation\n``` bash\n  npm install nconf --save\n```\n\n## Run Tests\nTests are written in vows and give complete coverage of all APIs and storage engines.\n\n``` bash\n  $ npm test\n```\n\n#### Author: [Charlie Robbins](http://nodejitsu.com)\n#### License: MIT\n\n[0]: http://github.com/indexzero/nconf-redis\n","funding_links":[],"categories":["JavaScript","Repository","others","Node.js"],"sub_categories":["Configuration Tools","常用NPM工具模块"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexzero%2Fnconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findexzero%2Fnconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexzero%2Fnconf/lists"}