Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
This package provides a convenient way to enable type-safety for environment variables in your Node.js application by wrapping the functionality of dotenv
and envalid
libraries.
You can install this package using npm:
npm install @daopk/env
To use this package, create a file named env.ts
in your source root folder and define your environment variables with their expected types using defineEnv
function. For example:
import { defineEnv, num, str } from '@daopk/env';
export const env = defineEnv({
NODE_ENV: str(),
SERVER_HOST: str({ default: 'localhost' }),
SERVER_PORT: num({ default: 3000 }),
});
After defining your environment variables, you can import the exported env variable from the env.ts
file.
import { env } from '~/env';
console.log(env.NODE_ENV); // Prints the value of NODE_ENV as a string
console.log(env.SERVER_HOST); // Prints the value of SERVER_HOST as a string
console.log(env.SERVER_PORT); // Prints the value of SERVER_PORT as a number
To use the ~
alias in your TypeScript project, you need to configure the paths option in the tsconfig.json
file. For example:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"~/*": ["./src/*"]
}
}
}
FAQs
dotenv + envalid
The npm package @daopk/env receives a total of 25 weekly downloads. As such, @daopk/env popularity was classified as not popular.
We found that @daopk/env demonstrated a healthy version release cadence and project activity because the last version was released less than 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.