@boundstate/env

Load and validate environment variables in node.js with TypeScript

Stats

StarsIssuesVersionUpdatedCreatedSize
@boundstate/env
6.0.0a year ago3 years agoMinified + gzip package size for @boundstate/env in KB

Readme

@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'));

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.