Developers can manage environment variables in various stages, such as production, test, development, etc. Developers can set default status by option or NODE_ENV. if you not set default status, it will be development Environment variables are created in the common.js and yourEnvironmentStatus.js However, if an environment variable is declared in an .env file or a system environment variable, that value takes precedence.
const configImporter = require('@araxsiyual/config-importer');
const config = configImporter.import(__dirname, /*option*/);{
"env";: process.env.NODE_ENV || "development",
"valueName";: "valueName",
"default";: "common"
}env: Environment status, it will readenv.js file, and make configvalueName: If object havevalueName, module usevalueName's value for read System value or .env, If the object does not have avalueName, module use object name for read System value or .envdefault: default environment file name
module.exports = {
parent: {
childA: 0,
childB: 0
}
}module.exports = {
parent: {
childA: 1
}
}module.exports = {
parent: {
childA: 2
}
}const configImporter = require('@araxsiyual/config-importer');
const config = configImporter.import(__dirname);
module.exports = config;-
config is
{ { 1, childB;: 0 } }
-
config is
{ { 2, childB;: 0 } }
module.exports = {
parent: {
childA: 0
}
}PARENT_CHILD_A = 1
- parent.childA will be 1
PARENT_CHILD_A = 1
PARENT_CHILD_A_DEVELOPMENT = 2
- parent.childA will be 2
module.exports = {
parent: {
valueName: 'p',
childA: 0
}
}P_CHILD_A = 1
- parent.childA will be 1
