
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
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 573 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.