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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@m1212e/konfigure

v0.0.10

Published

konfigure allows you to easily define a schema for your application config and provides flexible sources and proper helpful errors without the need to manually use and check for any env or config file!

Readme

konfigure

konfigure allows you to easily define a schema for your application config and provides flexible sources and proper helpful errors without the need to manually use and check for any env or config file!

Usage

Add the dependency

npm i @m1212e/konfigure
bun add @m1212e/konfigure

Then define a schema with either TypeBox, Zod or Valibot.

import { Type } from "@sinclair/typebox";

const appConfigSchema = Type.Object({
  foo: Type.String(),
  bar: Type.Optional(Type.Number()),
})

Afterwards, decide on which sources you would like to read for your config and in which order. Oftentimes, you'd have some mix of env vars and config file. Docker secrets are also supported. The available sources are exported from konfigure under the sources object.

import { env } from '@m1212e/konfigure/source/env.js';
import { dockerSecrets } from '@m1212e/konfigure/source/dockerSecrets.js';
import { jsonFile } from '@m1212e/konfigure/source/jsonFile.js';
import { object } from '@m1212e/konfigure/source/object.js';

const appConfigSources = [
  env(),
  dockerSecrets(),
  jsonFile(join(import.meta.dir, "example.json")),
  object({
    foo: "fallback",
    bar: 3,
  })
]

Notice how we put the static object in the last place in the array. This results in the fallback values having the lowest priority and therefore beeing overwritten whenever a higher order source has the value present.

Finally, we put together our schema and sources in the konfigure call to read our config.

import { konfigure } from "@m1212e/konfigure";
const configObject = await konfigure({
  schema: appConfigSchema,
  sources: appConfigSources,
});

This outputs a strongly typed object according to the schema we defined, populated by the sources we decided on.

If you would like to see some more elaborate examples, see the examples directory.

Path delimeter

In some cases we have some form of nested objects in our config. Say we want to group the db credentials and the host settings together in an object each. In cases like these you can use a delimeter ('_' per default) to set nested values in e.g. env vars or other sources which do not support nested data structures out of the box. Our konfigure call might look like this.

const configObject = await konfigure({
  // delimeter: "_", // optionally, you can change the delimeter
  schema: Type.Object({
    db: Type.Object({
      username: Type.String(),
      password: Type.String(),
      port: Type.String(),
      host: Type.String(),
    }),
    application: Type.Object({
      port: Type.String(),
      host: Type.String(),
    }),
  }),
  sources: [
    /*
      While our env vars are set like this:
      db_username: "username",
      db_password: "123",
      db_port: "8822",
      db_host: "localhost",
      application_port: "3000",
      application_host: "0.0.0.0",
    */
    env(),
  ],
});