@boundstate/env
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

@boundstate/env

Load and validate environment variables in node.js with TypeScript.

$ npm install @boundstate/env joi@^17

Usage

import { EnvManager } from '@boundstate/env';
import * as Joi from '@hapi/joi';

interface Env {
  DATABASE_URL: string;
  DEBUG: boolean;
  PORT: string;
}

const env = new EnvManager<Env>({
  schema: {
    DATABASE_URL: Joi.string(),
    DEBUG: Joi.boolean().truthy('1').falsy('0').optional().default(false),
    PORT: Joi.string(),
  },
});

env.load({
  dotenvPath: __dirname + '/../.env',
});

console.log(env.get('DEBUG'));

Readme

Keywords

none

Package Sidebar

Install

npm i @boundstate/env

Weekly Downloads

2

Version

6.0.0

License

MIT

Unpacked Size

8.25 kB

Total Files

7

Last publish

Collaborators

  • guiltyspark
  • mikejpeters