Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Hierarchical configuration, made easy.
In it's most basic usage, you can add configuration objects to a crampon instance and then access that configuration:
var Crampon = require('crampon'),
crampon = new Crampon().add({
root: '/home/apps/ftknox'
});
var config = crampon.getConfig();
Data can be added using the add
and addFile
methods. New data is merged with old data and if there are conflicts then new values will take precedence:
var crampon = new Crampon().add({
root: '/home/apps/ftknox',
db: {
name: 'ftknox',
pwd: '1234'
}
})
.addFile('./conf'); // could be conf.js or conf.json if extension is not specified
// conf.js: module.exports = { db: { pwd:'abcd' } };
assert.deepEqual(crampon.getConfig(), {
root: '/home/apps/ftknox',
db: {
name: 'ftknox',
pwd: 'abcd'
}
});
Hierarchical configuration can be used to setup environment specific configuration with the ability to inherit and override configuration for each environment:
// Set the hierarchy when constructing an instance of crampon
var crampon = new Crampon(['prod', 'test', 'dev']).add({
prod: {
root: '/home/apps/ftknox',
db: {
name: 'ftknox',
pwd: '1234'
},
debugLevel: 3
},
stage: {
debugLevel: 2
},
dev: {
db: {
name: 'ftknox_dev'
},
debugLevel: 1
}
});
// Get the dev configuration
var config = crampon.getConfig('dev');
// Note that the environment param defaults to the NODE_ENV environment variable
assert.deepEqual(config, {
root: '/home/apps/ftknox',
db: {
name: 'ftknox_dev',
pwd: '1234'
},
debugLevel: 3
});
When using a hierarchical configuration, data added via add
and addFile
must have environment keys at the root.
In order to override environment specific configuration with configuration that applies in all cases you can use addOverride
and addOverrideFile
.
Continuing the above example, you could override the debugLevel in your dev environment in this way:
crampon.addOverride({
debugLevel: 1
});
// Get the configuration
var config = crampon.getConfig('dev');
// debugLevel is now 1 in all environments
assert.deepEqual(config, {
root: '/home/apps/ftknox',
db: {
name: 'ftknox_dev',
pwd: '1234'
},
debugLevel: 1
});
As of version 0.2, arrays in configuration are replaced, rather than merged.
var crampon = new Crampon().add({
favoriteColor: 'pink',
otherColors: [
'blue',
'red'
]
})
.add({
otherColors: [
'green',
'black'
]
});
assert.deepEqual(crampon.getConfig(), {
favoriteColor: 'pink',
otherColors: [
'green',
'black'
]
});
FAQs
Hierarchical configuration, made easy.
The npm package crampon receives a total of 8 weekly downloads. As such, crampon popularity was classified as not popular.
We found that crampon 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.