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

@zudojs/config

v1.0.0

Published

Layered configuration management with multiple sources, validation, and environment-specific overrides.

Readme

@zudojs/config

Layered configuration management with multiple sources, priority-based merging, schema validation, and sensitive-value redaction.

Installation

npm install @zudojs/config

Quick Start

import {
  createConfigManager,
  createDefaultsConfigSource,
  createMemoryConfigSource,
} from "@zudojs/config";

const manager = createConfigManager({
  sources: [
    createDefaultsConfigSource({ "app.port": 3000, "app.name": "demo" }),
    createMemoryConfigSource(
      { "app.port": 8080 },
      { name: "overrides", priority: 100 },
    ),
  ],
});

await manager.load();

manager.number("app.port"); // 8080 (higher priority wins)
manager.string("app.name"); // "demo"

Or create and load in one step:

import { initializeConfigManager } from "@zudojs/config";

const manager = await initializeConfigManager({
  initialValues: { "app.env": "development" },
});

With autoLoad: true the manager starts loading on construction; await manager.ready() before reading values.

Sources

A source provides values plus a priority. Higher priority wins; equal priorities are applied in registration order (last registered wins).

  • createDefaultsConfigSource(values, name?) — low-priority defaults.
  • createMemoryConfigSource(values, { name, priority?, optional? }) — in-memory values.
  • createEnvironmentConfigSource({ prefix, env?, priority?, keyMapper?, isSensitive? }) — reads environment variables. Values stay RAW STRINGS (use the typed accessors to coerce, so "false" becomes false instead of a truthy string). Names matching a password/token/secret/API-key pattern are reported as sensitive and therefore redacted by toSafeObject().
  • createCustomConfigSource(name, loader, options?) — async loader function returning { values, source, type }. Include sensitiveKeys: ["some.key"] in the result to mark values as sensitive so they are redacted by safe serialization.
import {
  createEnvironmentConfigSource,
  createCustomConfigSource,
  ConfigSourceType,
} from "@zudojs/config";

// APP__DB__HOST=localhost -> "db.host"
const env = createEnvironmentConfigSource({ prefix: "APP__" });

const remote = createCustomConfigSource("vault", async () => ({
  values: { "db.password": "s3cret" },
  sensitiveKeys: ["db.password"],
  source: "vault",
  type: ConfigSourceType.CUSTOM,
}));

Typed access

ConfigManager (and the underlying ConfigResolver) offer typed getters: string(), number(), boolean(), bigint(), date(), object(), array(), get(), required(), and scoped(prefix) for prefix-scoped access.

const db = manager.scoped("db");
db.string("host", "localhost");

Schema validation

Schemas are plain objects validated by this package (no external validation library is used):

import { ConfigValueType } from "@zudojs/config";

const config = manager.validate({
  properties: {
    "app.port": { type: ConfigValueType.NUMBER, required: true },
    "db.password": { type: ConfigValueType.STRING, secret: true },
  },
  additionalProperties: true,
});

Object schemas nest: a property schema of type OBJECT that declares its own properties / additionalProperties is validated recursively, so nested constraints are enforced by validate(), resolve() and the standalone validateConfigValue.

validate() throws on failure and marks entries whose schema has secret: true as sensitive. Individual values can be validated with manager.resolve(key, schema) or the standalone validateConfigValue / validateConfigObject functions.

Redaction

  • manager.toObject() / store.toObject() return RAW values, including secrets.
  • manager.toSafeObject() / store.toSafeObject() replace sensitive values with "[REDACTED]" — use these for logging and diagnostics.

Reloading

manager.reload() re-runs all sources. Values set at runtime via manager.set() and initialValues survive loads; sources only overwrite entries at equal or higher priority.

Untrusted input

Configuration frequently originates from files, environment variables or remote services. Keys such as __proto__, constructor and prototype are copied with Object.defineProperty, never plain assignment, so a hostile key becomes an ordinary own property and can never replace an object's prototype. Schema properties are read as OWN properties, so a schema property named constructor is reported as missing rather than matching an inherited function.

Use Cases

  • Application configuration
  • Environment-specific settings (dev, staging, prod)
  • Feature flags and toggles
  • Secrets handling with redacted diagnostics