Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@mondora/env
Advanced tools
A better way to retrieve environment variables in nodejs.
Features:
NODE_ENV != production
process.env
yarn add @mondora/env
import env from "@mondora/env";
export const REQUIRED = env("REQUIRED", { required: true });
export const REQUIRED_ONLY_IN_PRODUCTION = env("REQUIRED_ONLY_IN_PRODUCTION", {
required: true,
nonProductionDefault: "DEFAULT"
});
export const NON_REQUIRED = env("NON_REQUIRED");
export const WITH_DEFAULT = env("WITH_DEFAULT", { default: "DEFAULT" });
// PARSED is a Buffer
export const PARSED = env("TO_BE_PARSED", {
required: true,
parse: value => Buffer.from(value)
});
Retrieves the specified environment variable.
name
string required: name of the environment variable to retrieveoptions
object:
required
boolean: marks the variable as required. Ie, if the variable
is not set, an error is thrownnonProductionDefault
boolean: makes a required variable only required
when NODE_ENV == production
, while giving it a default value otherwisedefault
string: a default value for the variable if it's not setparse
function: a function to transform the value of the variable (a
string) into whatever before it's returned by env
. The function is called
only when a value or a default value for the variable was setThe value of the environment variable, parsed by the options.parse
function if
specified.
Sets the input source from which environment variables are retrieved (the
default input source is process.env
).
inputSource
(string, string) map required: custom input sourceNothing.
To get started developing the library, clone the project and install
dependencies with yarn
. Then you can either:
yarn test
: runs testsyarn test --watch
: runs tests, re-runs them on code changesyarn coverage
: runs tests, measures code coverageyarn lint
: runs code linters (prettier + tslint)yarn prettify
: formats code with prettieryarn compile
: compiles the projectNOTE: this project uses prettier to enforce code formatting. Installing the prettier extension for your editor of choice is highly recommended.
Run npm version x.x.x
to bump a new version of the package. The command will
set the specified version number in package.json
, commit the change, tag the
commit with vx.x.x
Push the commit and the tag to github: git push --tags origin master
If linting and automated tests pass, the module will automatically be published to npm
Note: you can use convenience commands
npm version major
,npm version minor
,npm version patch
to bump the consecutive major / minor / patch version of the package.
FAQs
A better way to retrieve environment variables
We found that @mondora/env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.