1.0.8 • Published 6 months ago

pargali v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Pargali

Pargali is an enhanced environment variable loader for Node.js applications. It extends the basic functionality of dotenv, offering additional features such as type casting and mandatory variable checks. This makes the management of environment variables in Node.js applications easier, safer, and less error-prone, especially in complex projects.

Bugs Security Rating Maintainability Rating Code Smells Lines of Code Reliability Rating Duplicated Lines (%) Coverage

Features

  • Easy Loading: Simplifies the process of loading environment variables from a .env file.
  • Type Casting: Automatically casts environment variables to specified types (String, Number, Boolean), preventing type-related bugs.
  • Mandatory Variable Checks: Ensures critical environment variables are set, avoiding runtime errors in production.

Installation

Pargali requires Node.js. To install Pargali, use npm:

npm install pargali

Usage

To use Pargali, require it at the beginning of your application. This ensures all environment variables are loaded and available:

const Pargali = require('pargali').default;

Accessing Environment Variables

With Pargali, environment variables can be accessed in various types, each method providing additional safety and convenience over standard process.env:

As a String:

process.env.TEST_STRING = "Hello";
const someString = Pargali.getString('TEST_STRING'); // "Hello"

As a Number:

process.env.TEST_NUMBER = "123";
const someNumber = Pargali.getNumber('TEST_NUMBER'); // 123

As a Boolean:

process.env.TEST_BOOLEAN = "true";
const someBoolean = Pargali.getBoolean('TEST_BOOLEAN'); // true

As a String Array:

process.env.TEST_STRING_ARRAY = "apple, orange, banana";
const someStringArray = Pargali.getStringArray('TEST_STRING_ARRAY'); // ["apple", "orange", "banana"]

As a Number Array:

process.env.TEST_NUMBER_ARRAY = "1, 2, 3";
const someNumberArray = Pargali.getNumberArray('TEST_NUMBER_ARRAY'); // [1, 2, 3]

As a Boolean Array:

process.env.TEST_BOOLEAN_ARRAY = "true, false, yes, no";
const someBooleanArray = Pargali.getBooleanArray('TEST_BOOLEAN_ARRAY'); // [true, false, true, false]

Mandatory Variable Checks

To ensure vital environment variables are set, Pargali provides a method for mandatory checks:

const requiredVar = Pargali.require('REQUIRED_VAR');

If REQUIRED_VAR is not set, Pargali throws an error, ensuring the application's essential configurations are in place.

Meaning Behind the Package Name

Pargali Ibrahim Pasha, in his role as Grand Vizier, was instrumental to the Ottoman Empire, enhancing its administration and international standing, similar to how the Pargali npm package bolsters modern Node.js projects. Just as Ibrahim Pasha streamlined the empire's governance and established pivotal alliances through his skilled diplomacy, the Pargali package simplifies and secures environment variable management. It extends the basic functionality of dotenv, introducing features like type casting and mandatory variable checks. This not only reduces configuration errors but also makes the handling of environment variables more efficient and reliable, paralleling the way Ibrahim Pasha's reforms strengthened the Ottoman Empire's infrastructure and military prowess.

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago