Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Confide is a simple configuration module for node.js. It will merge an environment-specific configuration file with a default configuration file and return the merged values.
Assume the directory structure:
|- config
| |- default.json
| |- production.json
|- node_modules
| |- confide
|- myscript.js
Any property declared in a default config file may be overridden by an environment-specific config file.
// in default.json
{
"showLogMsgs": true // will be overridden below
"dateFormat": "MM/DD/YYYY" // will not be overridden below
}
// in production.json
{
"showLogMsgs": false
// inherit dateFormat
}
In myscript.js, we can read our configuration by invoking confide's load()
method:
var path = require('path'),
CONFIG_DIR = path.join(__dirname, 'config'),
confide = require('confide');
confide({configDir: CONFIG_DIR}).load('production', function (err, mergedConfig) {
mergedConfig.showLogMsgs; // false
});
The confide
function takes a number of parameters:
configDir
(required) - directory where configuration files are locateddefaultEnv
(optional, defaults to default
) - name of the default env (default json file)cache
(optional, defaults to true
) - whether to cache config values for future calls to load()
If you don't need environment-specific configuration, you can just create default.json in your config directory, and leave out the environment parameter when calling load()
:
confide({configDir: CONFIG_DIR}).load(function (err, defaultConfig) {
defaultConfig.showLogMsgs; // true
});
If cache is enabled (it is by default) and you wish to focibly reload your configuration, just call the reload()
method with the same parameters as load()
:
var conf = confide({configDir: CONFIG_DIR});
conf.load('production', function (err, mergedConfig) {
mergedConfig.showLogMsgs; // false
// production.json updated on the file system...
conf.reload('production', function (err, mergedConfig) {
mergedConfig.showLogMsgs; // true
});
});
FAQs
simple app configuration
The npm package confide receives a total of 2 weekly downloads. As such, confide popularity was classified as not popular.
We found that confide demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.