Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
envboss
Advanced tools
Readme
Tired of using process.env
everywhere in the code?
Tired of guessing which environment variable are mandatory
and which are optional
?
Tired of validating environment params?
meet EnvBoss!!!
This package will help you organize and validate all your environment variables in one place.
Installation
> npm i envboss
/// envVariablesConfig.js
import { createEnvObject, mandatory, Types } from 'envboss';
const ENV_VARS_CONFIG = {
CLUSTER: { mandatory: true },
ENVIRONMENT: { mandatory, validValues: ['live', 'sandbox']},
IS_MASTER: { mandatory, type: Types.Boolean },
IP_ADDRESSES_ARR: { mandatory, type: Types.Array }, //resolves as array of ip addresses
STORAGE_PORT: { mandatory, wrappingFunction: someFunc },
// optional
PORT: { default: 8082 },
PROCESSOR_TIMEOUT: { default: 50000},
RETRY_TIMES: { default: 10, validationFunction: (v) => v > 3},
LOG_LEVEL: { default: 'info' }
};
module.exports = createEnvObject(ENV_VARS_CONFIG);
/// someFile.js
const { ENVIRONMENT } = require('envVariavbesConfig.js');
It goes over the configuration you provide, and returns an object where the key
is the <ENV_PARAM_NAME>
and the value is process.env[<ENV_PARAM_NAME>]
after it was validated and sanitized.
mandatory
- when set to true, sets this param as mandatory. Can be used as mandatory
only when required from 'envboss';
default
- lets you define a default value.
type
- converts the given envParam value from 'string' to given Type. Supported types: Number, Boolean, String, Array
. By default,
if default
config is provided, process.env[<ENV_PARAM_NAME>]
value will be converted to the type default's value type
validationFunction
- will help you validate the values.
validValues
- lets you describe what values are valid.
wrappingFunction
- converts the envparam value to the given value.
If you wouldn't like to validate envparams (e.g. in tests) pass false to
createEnvObject(ENV_VARS_CONFIG,false)
FAQs
package for environment variables
The npm package envboss receives a total of 12 weekly downloads. As such, envboss popularity was classified as not popular.
We found that envboss demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.