Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@clocklimited/configury
Advanced tools
Readme
Easy management of environment based configuration
npm install configury
Using in-memory configuration
const configury = require('configury')
const config = configury()
Using configuration file on disk
const configury = require('configury')
const config = configury('./properties.json')
Using default config section other than 'global'
const configury = require('configury')
const config = configury('./properties.json', 'myDefaultConfigSection')
Using existing config object
const config = {
global: {
foo: 'bar'
},
sectionName: {
bar: 'baz'
}
}
const configury = require('configury')
const config = configury(config)
const configury = require('configury')
const config = configury('./properties.json')
config.raw()
//-> { "global": { "foo": "bar" }, "development": { "foo": "bar" } ... }
Save the current configuration in memory to disk
const configury = require('configury')
const config = configury('./properties.json')
// Write to './properties.json' file on disk synchronously
config.write()
// Write to './properties.json' file on disk asynchronously
config.write(false, function (err) {
if (!err) console.log('Yeah')
})
// Write to './myBackupProperties.json' file on disk asynchronously
config.write('myBackupProperties.json', function (err) {
if (!err) console.log('Yeah')
})
// Write to './myBackupProperties.json' file on disk synchronously
config.write('myBackupProperties.json')
Setting a variable in 'global' configuration
const configury = require('configury')
const config = configury('./properties.json')
config.set('Alice', 'Bob')
config.raw()
//-> { "global": { "Alice": "Bob" } ... }
Setting a variable in 'myCustomGlobal'
const configury = require('configury')
const config = configury('./properties.json', 'myCustomGlobal')
config.set('Alice', 'Bob')
config.raw()
//-> { "myCustomGlobal": { "Alice": "Bob" } ... }
const configury = require('configury')
const config = configury('./properties.json', 'myCustomGlobal')
const mySection = config.section('mySection')
//-> mySection = { set: function(key, value), merge: function(object) }
Setting a variable in 'mySection'
const configury = require('configury')
const config = configury('./properties.json')
const mySection = config.section('mySection')
mySection.set('Alice', 'Bob')
config.raw()
//-> { "global": { ... } "mySection" { "Alice": "Bob" } }
Merging an object over a property in the configuration
const configury = require('configury')
const config = configury('./properties.json')
config.set('foo', 'bar')
//-> { "global": { "foo": "bar" } ... }
config.merge({ 'global': { 'foo': 'woo' }, 'pickles': 'bananas' })
//-> { "global": { "foo": "woo" }, "pickles": "bananas" }
Merging an object over a property in 'mySection'
const configury = require('configury')
const config = configury('./properties.json')
const mySection = config.section('mySection')
mySection.set('foo', 'bar')
//-> { "global": { ... } "mySection": { "foo": "bar" } }
mySection.merge({ 'foo': 'woo' })
//-> { "global": { ... } "mySection": { "foo": "woo" } }
By default, configury will substitute any values that match the pattern: %string%
. This will substitute the current value with the value of that key if it exists. E.g:
const configury = require('configury')
const config = configury()
config.set('url', 'http://localhost:3000')
config.set('loginUrl', '%url%/login')
console.log(config().loginUrl)
//-> 'http://localhost:3000/login'
Paul Serby follow me on twitter @serby
Licensed under the New BSD License
FAQs
Easy management of environment based configuration
The npm package @clocklimited/configury receives a total of 29 weekly downloads. As such, @clocklimited/configury popularity was classified as not popular.
We found that @clocklimited/configury demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.