
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
diamorphosis
Advanced tools
Use
to configure your application for different environments (NODE_ENV). Supports defaults. Supports nested values.
$ npm install diamorphosis
// file: config/config.js
{
my_var_a : "some value",
myVarB: "some value"
}
// file: config/env/production.json
{
"nested":{
"my_var_a" : "some production value",
"myVarB": "some production value"
}
}
To enable the production configuration set NODE_ENV=production
export NESTED_MY_VAR_A=someScalarValue
export NESTED_MY_VAR_B=this,var,is,an,array,of,values // NESTED_MYVARB is also supported
export NESTED_BOOLEAN=true
NESTED_MY_VAR_A=someValue
// file: config/config.js
// var names should be snakecase (a_var_example) in order to be able to overwrite them correctly using env vars.
module.exports =
{
varOne: '1_dev_',
nestedExample: {
varTwo: '2_dev_'
}
}
// file: config/evn/production.json
{
"varOne": '1_prod',
"nestedExample": {
"varTwo": "2_prod"
}
}
// file: config/evn/other.json
{
"varOne": '1_other',
"nestedExample": {
"varTwo": "2_other"
}
}
// file: app.js
const diamorphosis = require('diamorphosis');
diamorphosis({ // these are the default values
configFolder: './config',
configPath: './config/config.js',
envFolder: './config/env',
loadDotEnv: ['development'] // will only load .env if NODE_ENV=development
})
// file: myFile.js
const config = require('./config/config');
console.log(var_one:', config.var_one);
console.log(var_two:', config.nested_example.varTwo);
// Env vars can overwrite the config values. The app will need a restart to load the new values:
// export VAR_ONE="some other value for var one"
// export NESTED_EXAMPLE_VAR_TWO="some other value for var two"
# file .env
VAR_ONE=value
Config.js can use the es6 export default eg:
export default {
varOne: '1_dev_',
nestedExample: {
varTwo: '2_dev_'
}
}
This is especially useful if you are using diamorphosis with typescript.
Note that env files can have .json or .js extension
MIT
FAQs
Use - JSON file(s) - .env file for development - ENV vars
We found that diamorphosis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.