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

@ace-common/config

v2.1.2

Published

Type-safe, validated environment configuration for NestJS

Downloads

510

Readme

@ace-common/config

Type-safe, validated environment configuration for NestJS. Define your env schema as a class, get instant startup validation and typed injection everywhere.

Installation

pnpm add @ace-common/config

Peer dependencies: @nestjs/common, @nestjs/core, reflect-metadata.

Quick Start

1. Define your config schema

import {
  EnvString,
  EnvPort,
  EnvBoolean,
  EnvBooleanOptional,
  EnvStringOptional,
} from "@ace-common/config";

export class AppConfig {
  @EnvPort()
  PORT: number;

  @EnvString()
  JWT_SECRET: string;

  @EnvString()
  DATABASE_URL: string;

  @EnvStringOptional()
  APP_NAME?: string;

  @EnvBooleanOptional()
  DEBUG?: boolean;
}

2. Register the module

import { configureConfig } from "@ace-common/config";
import { AppConfig } from "./app.config";

@Module({
  imports: [
    configureConfig({ schema: AppConfig }),
    // ... other modules
  ],
})
export class AppModule {}

On startup, if any env var is missing or invalid, the app crashes immediately with a clear message:

ConfigValidationException: Environment configuration validation failed:
  - JWT_SECRET: JWT_SECRET should not be empty
  - DATABASE_URL: DATABASE_URL should not be empty
  - PORT: PORT must be an integer number

3. Inject the typed config

import { InjectConfig } from "@ace-common/config";
import { AppConfig } from "./app.config";

@Injectable()
export class MyService {
  constructor(@InjectConfig() private readonly config: AppConfig) {}

  connect() {
    console.log(this.config.DATABASE_URL); // string, typed
    console.log(this.config.PORT); // number, already converted
  }
}

Options

configureConfig({
  schema: AppConfig,
  envFilePaths: [".env.local", ".env"], // default
  skipEnvFile: false, // set true in production
});

| Option | Default | Description | | -------------- | ------------------------ | -------------------------------------------- | | schema | required | Class decorated with validation decorators | | envFilePaths | [".env.local", ".env"] | .env files to load (first wins) | | skipEnvFile | false | Skip dotenv loading, read only process.env |

Built-in Decorators

| Decorator | Type | Required | Description | | ----------------------- | ---------- | -------- | ----------------------------------------- | | @EnvString() | string | Yes | Non-empty string | | @EnvStringOptional() | string? | No | Optional string | | @EnvNumber() | number | Yes | Numeric value | | @EnvNumberOptional() | number? | No | Optional number | | @EnvPort() | number | Yes | Integer >= 0 | | @EnvBoolean() | boolean | Yes | Accepts "true", "1", "false", "0" | | @EnvBooleanOptional() | boolean? | No | Optional boolean |

You can also use any class-validator / class-transformer decorator directly on your schema class for custom validation (e.g. @IsUrl(), @IsEnum(), @Matches()).

Exports

| Export | Description | | ------------------------------ | ---------------------------------------------- | | configureConfig | Module configuration helper | | AceConfigModule | NestJS dynamic module (forRoot) | | InjectConfig | Parameter decorator for typed config injection | | ConfigValidationException | Thrown on validation failure | | validateConfig | Standalone validation function | | EnvString, EnvNumber, etc. | Built-in schema decorators |

License

MIT