npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pargali

v1.0.8

Published

Enhanced environment variable loader for Node.js

Downloads

1

Readme

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.