@hodfords/env-parser
v0.0.4
Published
<p align="center"> <a href="http://opensource.hodfords.uk" target="blank"><img src="https://opensource.hodfords.uk/img/logo.svg" width="320" alt="Nest Logo" /></a> </p>
Downloads
115
Readme
Installation 🤖
To begin using it, we first install the required dependencies.
npm install @hodfords/env-parserUsage 🚀
Create .env file, you can also pass it via environment variable without creating a file.
APP_PORT=3000
REDIS_PORT=6379
REDIS_HOST=localhost
ALLOW_SEND_MAIL=trueCreate env file like env.ts and import parse and z from @hodfords/env-parser.
import { parse, z } from '@hodfords/env-parser';
export const env = parse(process.env, {
APP_PORT: z.number().min(1000).max(9999),
REDIS: {
PORT: z.number().default(6379),
HOST: z.string().default('localhost')
},
ALLOW_SEND_MAIL: z.boolean().default(true)
});Note: env-parser supports multiple parser levels, but we recommend using up to 2 levels to ensure easier code readability.
More validation function here: Zod Validation
License
This project is licensed under the MIT License
