Observed since 20 Oct, 18:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Include dotenv files in relative path tree, and parse with 12factor config
.env)This module looks for .env files loads them with node-env-file and returns a 12factor-config
Features
.env files in an ascending relative path:
./../../../npm install 12factor-dotenv --save
This module uses 12factor-config to manage a config schema, for configuration support, Read More Here
in a single config file (obey 12factor and unify your config location), do something like:
// in ./app/lib/config.js
var config = require('12factor-dotenv');
var schema = {
DEBUG: {
env: 'DEBUG', // the environment export var to read
type: 'boolean', // config var type (string, integer, boolean - maybe more see 12factor-config)
default: false
},
PORT: {
env: 'PORT',
type: 'integer',
default: 4000
},
MY_CUSTOM_VAR: {
env: 'MY_LOCAL_ENVIRONMENT_EXPORT_VAR',
type: 'string'
},
NODE_ENV: {
env: 'NODE_ENV',
type: 'string',
default: 'development'
}
};
var cfg = config(schema, { debug: true, env: { overwrite: true } });
## See https://www.npmjs.com/package/node-env-file#api for more details on `env` options
console.log('info: -- PORT is', cfg.PORT);
console.log('info: -- NODE_ENV is', cfg.NODE_ENV);
console.log('debug: -- ENV Debug is', process.env.DEBUG);
console.log('debug: -- ENV Port is', process.env.PORT);
console.log('info: < Configured.');
module.exports = exports = cfg;
now var cfg = require('./path/to/app/lib/config.js'); wherever you want your unified config - and keep .env(s) updated per environment.
Note!
This package also loads native process.env variables, when parsing .env files
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 18:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:cb7d1a0625d86dbc71104f5977f03b022fe4084f36c10b80c147b9c17c1914b4