
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Load config from a javascript object.
When JSON is too limiting; you need to dynamically set values, include comments or external files in your configuration, jsconf is the tool for you.
npm i jsconf --save
load from a file
var jsconf = require('jsconf')
var config = jsconf.load('/path/to/config.jsconf')
console.log(config)
parse a string
var config = jsconf.parse('{x: +new Date}')
console.log(config)
load from a file with exposed variables
var jsconf = require('jsconf')
// The jsconf object will now have access the variable `cwd`
jsconf.context.cwd = process.cwd()
var config = jsconf.load('/path/to/config.jsconf')
console.log(config)
A jsconf file contains a single javascript object declaration. There cannot be any executable code outside the object. Comments are allowed anywhere.
These are the perks:
Dynamic Properties
{
created: +new Date,
nuance: ~~(100 + (Math.random() * 1000)),
guid: (function(x){return x % 200})(+new Date) // closure FTW!
}
C-style Comments
/**
* Database Configuration
* blah blah blah
*/
{
mysql: {
host: '127.0.0.1',
port: 3306,
user: 'DB_USER',
password: 'DB_PASS',
database: 'DB_NAME',
//socketPath: '/opt/local/var/run/mysql55/mysqld.sock',
// Settings
connectionLimit: 10, // Max number of connections to create at once
multipleStatements: true, // Allow multiple mysql statements per query
},
}
Include External Files
{
https: {
port: 443,
creds: {
'key': fs.readFileSync('./app/config/ssl-certs/server.key'),
'cert': fs.readFileSync('./app/config/ssl-certs/server.crt'),
'ca': fs.readFileSync('./app/config/ssl-certs/ca.crt'),
'requestCert': true,
'rejectUnauthorized': false
}
},
}
FAQs
Load config from a javascript object
We found that jsconf 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.