
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
node-application-config
Advanced tools
Application config package that provides a config object with support for local overrides and environmental overrides
Package to provide application config with local config and environment support. This package allows you to simply override config variables by defining local config files or environment variables.
Also nodeEnv
, and isDebug
are set based on NODE_ENV
, which can be used in your code later on.
If you want to parse other environmental variables into your application config, and you
cannot (or you don't wanna) use process.env
you can use the parsing feature.
If you declare a config variable with the following pattern: ${ENV_VAR_NAME}
,
the config application will match it to the corresponding environment variable.
export TEST_ENV_VAR=foobar
{
"db": {
"host": "${TEST_ENV_VAR}"
}
}
In this case, config.db.host
will be parsed to "foobar".
If you need to require a json
- yes only json, 'cause securty - file, you can do that
with a special pattern. You need to use a relative filepath. If any error happens
during the require process, the variable will have the value REQUIRE_ERROR
and
will have the error message attached.
The pattern for this feature is: !{filepath.json}
.
foobar.json
{
"hello": "world"
}
config.json
{
"foobar": "!{./foobar.json}"
}
Results in:
{
"foobar": {
"hello": "world"
}
}
If you want to overwrite an array with a config variable (maybe you have a list of languages), you can overwrite the array with the following syntax:
ARRAY_ENV=str1|str2|str3
This feature is only necessary if you want to overwrite an array with environment variables,
since you can use arrays in the config.json
and the config.local.json
files.
If you want to overwrite a variable with a single element array or even an empty array,
you can simply pass str1|
for a single element array or |
for an empty array.
export app_config_arrayType=string1|string2|string3
export app_config_emptyArrayType=|
export app_config_singleElementArrayType=string1|
Results in:
{
"arrayType": [
"string1",
"string2",
"string3"
],
"emptyArrayType": [],
"singleElementArrayType": [
"string1"
]
}
var appConfig = require('node-application-config'),
config = appConfig(options);
options
is a hash with the following config variables:
Base path for the application and for the config package to search for configurations
default: process.cwd()
Name of the base configuration
default: config.json
Name of the local configuration (which overwrites the base config, but is not necessarily in the version control)
default: config.local.json
Name of the environment configuration (which overwrites the base config, but is not necessarily in the version control)
ENV
will be replaced with process.env.NODE_ENV
!
default: config.ENV.json
Prefix for environment variables that overwrite the configurations
default: app_config_
Which character is used for splitting the environment variables after the prefix is removed.
default: _
Enable the automatically set nodeEnv
, isDebug
, isStage
and isProduction
config variables, based on NODE_ENV
.
If no NODE_ENV
is set, development
is taken as fallback value.
default: true
When merging config variables, the following priorities are taken into account:
config.json
{
"db": {
"user": "test",
"pass": "testPass",
"port": "10000"
}
}
config.local.json
{
"db": {
"pass": "securePass",
"host": "localhost"
}
}
environment variable
app_config_db_port=1337
... results in:
var appConfig = require('node-application-config'),
config = appConfig();
config.db.user == "test";
config.db.pass == "securePass";
config.db.host == "localhost";
config.db.port == 1337;
FAQs
Application config package that provides a config object with support for local overrides and environmental overrides
The npm package node-application-config receives a total of 12 weekly downloads. As such, node-application-config popularity was classified as not popular.
We found that node-application-config demonstrated a not healthy version release cadence and project activity because the last version was released 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.