Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@labdigital/enviconf
Advanced tools
A simple configuration library that loads configuration from environment variables and provides a simple interface to access them.
Inspired by https://github.com/caarlos0/env
import { BaseConfig, EnviConfig, envfield } from "@labdigital/enviconf";
class SampleConfig extends BaseConfig {
/** The port number to listen on */
readonly HTTP_PORT: number = 4000
config(): EnviConfig {
return {
HTTP_PORT: envfield.number({
// optional, defaults to false. Sets empty value if no env variable is set
optional: true,
// optional, defaults to false. Unsets the env variable after reading
unset: true,
// optional, env variable to read the value from, defaults to the property name
envName: "MY_HTTP_PORT",
// optional, defaults to undefined. Allows setting a custom validator, should
// throw an error if the value is invalid
validator: (value: number) => value > 0,
}),
}
}
}
const config = SampleConfig.load()
config.HTTP_PORT === 4000
import { BaseConfig, envprop } from "@labdigital/enviconf";
class SampleConfig extends BaseConfig {
@envprop.string()
public readonly MY_STRING_VARIABLE: string = "default value";
@envprop.number()
public readonly MY_NUMBER_VARIABLE: number = 123;
// Read JSON values
@envprop.object()
public readonly MY_OBJECT_VALUE: object = { foo: "bar" };
@envprop.number({
// optional, defaults to false. Sets empty value if no env variable is set
optional: true,
// optional, defaults to false. Unsets the env variable after reading
unset: true,
// optional, env variable to read the value from, defaults to the property name
envName: "MY_OTHER_ENV_VARIABLE",
// optional, defaults to ", ". Allows setting a custom separator for array values
envSeparator: ", ",
// optional, defaults to undefined. Allows setting a custom validator, should
// throw an error if the value is invalid
validator: (value: number) => value > 0,
})
public readonly ALL_OPTIONS: number = 123;
}
const config = SampleConfig.load({
// optional, path to the .env values, defaults to ".env"
path: ".env",
// optional, indicates if a .env file should be read, defaults to true
loadEnv: true,
// optional, if set, will be used as prefix for all env variables while
// falling back to the original name if the prefixed variable is not set
envPrefix: "MY_APP_",
})
FAQs
A simple library to parse environment variables
The npm package @labdigital/enviconf receives a total of 866 weekly downloads. As such, @labdigital/enviconf popularity was classified as not popular.
We found that @labdigital/enviconf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.