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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mylilapps/config-validator

v1.0.0

Published

"A robust configuration loader that wraps dotenv to provide mandatory, secure validation for critical environment variables. Ensures your application fails fast if any essential secrets (like DATABASE_URL or API_KEY) are missing.

Downloads

2

Readme

@mylilapps/config-validator

A robust, single-package solution for Node.js that wraps dotenv to enforce mandatory validation of critical environment variables. Ensure your application fails fast and clearly if essential secrets are missing or empty.

Why Use This?

In modern Node.js and Next.js applications, missing a single environment variable (like DATABASE_URL or a SECRET_KEY) can lead to cryptic errors or security vulnerabilities at runtime.

This module enforces Developer Discipline by loading your .env file and checking a list of required keys. If any key is missing or blank, the application is immediately shut down with a detailed, human-readable error report, preventing silent failures and deployment headaches.

Installation

This module sub-depends on the official dotenv library.

npm install @mylilapps/config-validator

Quick Start (ESM Example)

1. Create a .env File

Place your sensitive variables in a .env file at the root of your project:

# .env
# This variable is required by your application
DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"

2. Define and Validate

In your main entry file (server.js or index.js), you define an array of variables that must be present.

// server.js or your application entry point

import { loadAndValidateConfig } from '@mylilapps/config-validator';

// --- Define the keys required for your application to run ---
const REQUIRED_KEYS = [
    'DATABASE_URL', 
    'SECRET_KEY',
    'SERVER_PORT'
];

// --- Load and Validate ---
// This function will throw a FATAL error if any key in the array is missing.
// If successful, it returns a clean object with only the validated keys.
const config = loadAndValidateConfig(REQUIRED_KEYS);


// 🚀 Application can now start safely!
const PORT = config.SERVER_PORT || 8080;

console.log(`Server running securely on port ${PORT}`);
console.log(`Database URL loaded: ${config.DATABASE_URL.substring(0, 20)}...`);

Core Features

Single-Step Setup: Replaces complex environment validation boilerplate.

Zero Silent Failures: Application terminates immediately if a critical key is missing, saving hours of debugging time.

Clean Output: Returns a concise JavaScript object containing only the required keys, preventing unnecessary exposure of other environment variables.

ESM Ready: Fully designed for modern JavaScript projects using the import syntax.

Validation Logic Example

The validator checks for three conditions on every required key:

Is the variable defined?

Is the value an empty string?

Does the value contain only whitespace (e.g., " " or "")?

If any of these are true, the module throws the following detailed error, preventing application startup:

Error:
--- FATAL CONFIGURATION ERROR ---
The following essential environment variables are missing or empty:
[ DATABASE_URL, SECRET_KEY ]
Please update your .env file and try again.