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

envguardr

v1.1.0

Published

Fail-fast CLI to validate environment variables using a strict schema.

Readme

envguardr

tests npm npm audit signatures license

Fail-fast CLI to validate environment variables using a strict schema.

envguardr is a lightweight CLI that validates environment variables at build-time or runtime using a schema authored in TypeScript and compiled to JavaScript. Built on top of valitype, it helps catch misconfigurations early and integrate safely into CI/CD pipelines or local builds.

Features

  • CLI for validating process.env
  • Built with strict runtime types (string, number, boolean, url, enum)
  • Support for custom validators with helpful utilities
  • Validates required variables or applies defaults
  • Fails fast with clear error messages
  • Ideal for CI/CD pipelines or local builds

Installation

npm install --save-dev envguardr

Usage

npx envguardr validate ./env.schema.js

You can also add it as a script in your package.json:

"scripts": {
  "check-env": "envguardr validate ./env.schema.js"
}

Example Schema

import { validators } from 'valitype';

export default {
  // Basic types
  API_URL: { type: 'url', required: true },
  NODE_ENV: {
    type: { enum: ['development', 'production'] },
    default: 'development'
  },
  PORT: { type: 'number', default: 3000 },
  DEBUG: { type: 'boolean', default: false },
  VERSION: { type: 'string', required: true },
  
  // Custom validators
  API_KEY: { 
    type: 'custom', 
    validator: validators.regex(/^[A-Za-z0-9]{32}$/, 'API_KEY must be a 32-character alphanumeric string'),
    required: true
  },
  
  CACHE_TTL: {
    type: 'custom',
    validator: validators.range(0, 86400, 'Cache TTL must be between 0 and 86400 seconds'),
    default: '3600'
  },
  
  AWS_S3_BUCKET: {
    type: 'custom',
    validator: validators.awsArn('s3', 'Must be a valid S3 bucket ARN'),
    required: true
  }
}

What it does

  • Validates all variables defined in the schema
  • Fails if any required variable is missing or invalid
  • Uses defaults if provided
  • Logs output like:
❌ API_URL is required and must be a valid URL
❌ API_KEY must be a 32-character alphanumeric string
✅ All environment variables are valid.

Returns exit code 1 on failure — perfect for CI pipelines.

Types

type Rule =
  | { type: 'string'; required?: boolean; default?: string }
  | { type: 'number'; required?: boolean; default?: number }
  | { type: 'boolean'; required?: boolean; default?: boolean }
  | { type: 'url'; required?: boolean; default?: string }
  | { type: { enum: string[] }; required?: boolean; default?: string }
  | { type: 'custom'; validator: CustomValidatorFn; required?: boolean; default?: string; errorMessage?: string }

Custom Validators

The library includes several built-in validator utilities:

Regex Validator

validators.regex(/^[A-Z]{3}$/, 'Must be 3 uppercase letters')

Range Validator

validators.range(1, 100, 'Value must be between 1 and 100')

OneOf Validator

validators.oneOf(['apple', 'banana', 'orange'], 'Must be a valid fruit')

Date Validator

validators.date('YYYY-MM-DD', 'Must be a valid date')

JSON Validator

validators.json('Must be valid JSON')

AWS ARN Validator

validators.awsArn('lambda', 'Must be a valid Lambda ARN')

Combining Validators

validators.all(
  validators.regex(/^[A-Z]/),
  validators.oneOf(['Alpha', 'Beta', 'Gamma'])
)

Contributing

Contributions are welcome. See CONTRIBUTING.md.

License

This library is licensed under the MIT License. See the LICENSE file for details.