
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@freighthub/typed-env
Advanced tools
Enforceable environment variable contracts at runtime.
Use this library to make sure all the environment variables used in a project are valid.
To use the library, first declare a schema that consists of groups. A group is
a set of related environment variables that typically share a common prefix.
Groups are created using envGroup function that accepts a dictionary which
contains variable names and their types, e.g.:
import * as typedEnv from '@freighthub/typed-env'
const statsd = typedEnv.envGroup({
HOST: NonEmptyString,
PORT: PortNumber,
PREFIX: NonEmptyString,
}, 'STATSD')
const schema = typedEnv.envSchema({
statsd: statsd,
})
In the above example statsd group will be used to load variables
STATSD_HOSTSTATSD_PORTSTATSD_PREFIXThe optional STATSD prefix is passed as the second parameter to envGroup.
The schema is then created using envSchema function that accepts a dictionary
of groups.
To validate environment variables, make sure they're set (use dotenv.config()
to load .env if required). Then use loadFromEnv as follows:
const env = typedEnv.loadFromEnv(schema)
If any variables are missing or don't pass type checking, an exception will occur.
typed-env provides the following schema types:
Number - any numberInteger - integer numberPortNumber - integer number between 1 and 65535NonEmptyString - non-empty string of any lengthURI - URI as checked by valid-urlBoolean - true or falseUnion - a collection of string literals to resctrict a variable's possible valueimport * as typedEnv from '@freighthub/typed-env'
const schema = typedEnv.envSchema({
elasticSearch: typedEnv.envGroup({
URL: typedEnv.types.URI
}, 'ELASTICSEARCH'),
})
const env = typedEnv.loadFromEnv(schema)
console.log(env.elasticSearch.URL)
FAQs
Enforceable environment variable contracts at runtime
The npm package @freighthub/typed-env receives a total of 34 weekly downloads. As such, @freighthub/typed-env popularity was classified as not popular.
We found that @freighthub/typed-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 41 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.