Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@4c/env
Advanced tools
Readme
A small set of utils for working with environment variables in node and webpack projects. Wraps the excellent getEnv
as well
import * as Env from '@4c/env';
env
wraps and reexports getEnv
as get()
.
Env.get('NODE_ENV'); // 'production'
// Fails hard on missing variables
Env.get('NOT_SET_VAR'); // Error
// Fall back to a default if needed
Env.get('NOT_SET_VAR', 'default_value'); // 'default_value'
// Parsing
Env.get.int('MAX_SUBSCRIPTIONS', 4);
process.env.BOOLISH = 1;
Env.get.boolish('BOOLISH'); // true
.env
filesenv
will load and parse .env
files, by environment. We use the naming convention variables-{ENV}.env
to split out variables by different environment. The default is dev
.
Env.load(); // adds variables-dev.env to process.env
Env.load('test'); // adds variables-test.env to process.env
There is also a utility for passing enviroment variables to webpack's DefinePlugin
allowing instances of process.env.FOO
in front-end code to be replaced with a specific compile-time value.
// returns variables-test.env mapped to an object keyed by process.env.[foo] for use in webpack
new webpack.DefinePlugin(Env.define('test'));
FAQs
Environment variable management and helpers
The npm package @4c/env receives a total of 328 weekly downloads. As such, @4c/env popularity was classified as not popular.
We found that @4c/env 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
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.