npm

eris-env
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Eris Env Loader

About package

ErisEnvLoader is a simple package that aims to simplify the initialization of environment variables from .env files in Node.js projects.

Installation

npm i eris-env

Usage

  • Create a .env file in the root folder of your project and define your environment variables in the format KEY=VALUE. For example:
DATABASE_DIALECT=postgres
DATABASE_HOST=localhost
DATABASE_PORT=5432
  • Create a config.js file in the root folder of your project and define package.
// ES6
import { ErisEnvLoader } from 'eris-env';
// CommonJS
const ErisEnvLoader = require('eris-env');

const envLoader = new ErisEnvLoader();
  • Initialize variable:
const config = {
  database: {
    dialect: envLoader.getEnv('string', 'DATABASE', 'DIALECT'),
    host: envLoader.getEnv('string', 'DATABASE', 'HOST'),
    port: envLoader.getEnv('number', 'DATABASE', 'PORT'),
  },
};

Readme

Keywords

Package Sidebar

Install

npm i eris-env

Weekly Downloads

1

Version

0.0.6

License

ISC

Unpacked Size

6.13 kB

Total Files

7

Last publish

Collaborators

  • memusins