@i4you/env-config
v1.0.2
Published
Load the environment variable and Validate the env described in 'env-config.js' file and create appropriate getters also with full type safety.
Downloads
6
Maintainers
Readme
env-config
env-config is a utility package for loading environment variables and providing appropriate getters for them.
Features
- Load environment variables from
.envfiles. - Provide type-safe getters for environment variables.
- Simplify environment variable management in your projects.
Installation
npm install env-config
yarn add env-config
pnpm add env-config
bun add env-configUsage
Create a .env file in the root of your project: PORT=3000 DATABASE_URL=mongodb://localhost:27017/mydb
Use the env-config package in your project:
import { getEnv } from 'env-config';
const port = getEnv('PORT');
const databaseUrl = getEnv('DATABASE_URL');
console.log(`Server running on port: ${port}`);
console.log(`Database URL: ${databaseUrl}`);License
This project is licensed under the ISC License.
Author
rahil234
