@boundstate/env
v6.0.0
Published
Load and validate environment variables in node.js with TypeScript
Downloads
44
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'));