
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
dotenv-json-complex
Advanced tools
Load complex enviroment variable via JSON file
With Nodejs installed run the installation command in a terminal:
npm install dotenv-json-complex
Create a .env.json
file in the root of your project:
{
"my_app_env": {
"nodeEnv": "development",
"api": {
"prefix": "/api"
},
"database": {
"username": "foo",
"password": "bar",
"name": "awesome_db_name",
"host": "my_db_host"
}
}
}
After that, load your environment variables by requiring the dotenv dotenv-json-complex and executing it:
// here you load the json to your process.env
require("dotenv-json-complex")();
const env = JSON.parse(process.env.my_app_env);
// this will print your complex json environment!
console.log(env)
// like this
{
"nodeEnv": "development",
"api": {
"prefix": "/api"
},
"database": {
"username": "foo",
"password": "bar",
"name": "awesome_db_name",
"host": "my_db_host"
}
}
Furthermore you can provide an object to change environment filename:
require("dotenv-json-complex")({ environment: 'qa' });
This will look for .env.qa.json
file and load it in memory.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
FAQs
Load complex enviroment variable via JSON file
The npm package dotenv-json-complex receives a total of 635 weekly downloads. As such, dotenv-json-complex popularity was classified as not popular.
We found that dotenv-json-complex 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
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.