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

denvmon

v1.0.3

Published

denvmon is a TypeScript library for parsing and validating environment variables using class models and decorators. It supports primitive types with customizable validation and default values for a robust configuration experience.

Readme

Denvmon

Denvmon is a powerful utility for parsing environment variables using a class model structure. It leverages TypeScript decorators to define and validate environment variables based on their types.

Features

  • Support for environment variables of type STRING, NUMBER, and BOOLEAN.
  • Configurable properties such as defaultValue, required, and validation rules like min, max, or allowed values.
  • Uses TypeScript decorators for clean and declarative configuration.

Installation

Install the package using npm or yarn:

npm install denvmon

tsconfig.json

{
    "compilerOptions": {
      "experimentalDecorators": true,
    },
}

Usage

Step 1: Define Your .env File

Create a .env file in the root of your project with the following contents:

TIMEOUT=3000
IS_PRODUCTION=false
APP_NAME=MyApp
DATABASE_URI=test
DURATION=4.5

Step 2: Import the Required Modules

import { Denvmon, IsString, IsNumber, IsBoolean } from "denvmon";

Step 3: Define Your Class Model

Define your environment variables using the provided decorators:

import { Denvmon, IsBoolean, IsNumber, IsString } from "denvmon";

@Denvmon()
class Config {
  @IsString("DATABASE_URI")
  DATABASE_URI!: string;

  @IsNumber("TIMEOUT", {
    isInt: true,
  })
  timeout!: number;

  @IsNumber("TIMEOUT")
  sleep!: number;

  @IsBoolean("IS_PRODUCTION")
  is_production!: boolean;

  @IsNumber("DURATION")
  duration!: number;

  @IsBoolean("CUSTOM_BOOLEAN", {
    types: ["yes", "no"],
  })
  custom_boolean!: boolean;
}

const config = new Config();
console.log(config);

Example Output

When you run the above code with the .env file provided, you will get the following output:

{
  DATABASE_URI: "test",
  timeout: 3000,
  sleep: 3000,
  is_production: false,
  duration: 4.5,
  custom_boolean: false
}

API Reference

@IsString

Defines a string environment variable.

@IsString(key: string, {
  defaultValue?: string;
  required?: boolean;
  max?: number;
  min?: number;
})
  • key: The name of the environment variable.
  • defaultValue: The default value if the variable is not set.
  • required: Whether the variable is required (default: true).
  • max: Maximum string length.
  • min: Minimum string length.

@IsNumber

Defines a number environment variable.

@IsNumber(key: string, {
  defaultValue?: number;
  required?: boolean;
  isInt?: boolean;
})
  • key: The name of the environment variable.
  • defaultValue: The default value if the variable is not set. Supports integers and floats.
  • required: Whether the variable is required (default: true).
  • isInt: Whether the number must be an integer.

@IsBoolean

Defines a boolean environment variable.

@IsBoolean(key: string, {
  defaultValue?: boolean;
  required?: boolean;
  types?: [string, string];
})
  • key: The name of the environment variable.
  • defaultValue: The default value if the variable is not set.
  • required: Whether the variable is required (default: true).
  • types: The string representation of true and false values.

Custom Boolean Types Example

You can define custom string representations for boolean values using the types option:

@IsBoolean("CUSTOM_BOOLEAN", {
  types: ["yes", "no"],
})
custom_boolean!: boolean;

In the .env file, you can use:

CUSTOM_BOOLEAN=yes

The custom_boolean property in the class will then be set to true if the value is "yes" or false if the value is "no".