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

stilla

v2.2.0

Published

Flexible configuration management system for files and env variables

Readme

Stilla

Release codecov

Stilla is a flexible configuration management system that allows you to define and resolve configurations from various sources, such as environment variables and files in different formats (JSON, YAML, TOML, etc.). It uses a schema to validate and parse the configurations, ensuring that the configuration values are of the expected types.

Features

  • Multiple Configuration Providers: Supports reading configurations from environment variables and files.
  • Schema Validation: Uses zod for schema validation and parsing.
  • Type Hinting: Uses type hints from the schema to parse environment variables.
  • Nested Configuration: Supports nested configurations and arrays.
  • Customizable: Easily extendable by adding new configuration providers.

Installation

Install the package using your favorite package manager:

npm install stilla
pnpm add stilla
yarn add stilla

Usage

Define a Schema

First, define a schema using zod:

import { z } from 'zod';

const schema = z.object({
    key1: z.string(),
    key2: z.number(),
    nested: z.object({
        key3: z.boolean(),
    }),
    array: z.array(z.object({
        key4: z.string(),
    })),
});

Create a ConfigResolver

Create a ConfigResolver instance with the schema:

import { ConfigResolver } from "stilla";

const resolver = ConfigResolver.default(schema);

This will create a default resolver. It will first parse all your config files located in the "config" folder in the current working directory and then override anything found in environment variables.

Alternatively, you can create a resolver with custom configuration:

import { ConfigResolver } from "stilla";

const resolver = new ConfigResolver(schema);
resolver.addProvider(new FileConfigProvider({ basePath: "/path/to/config" }), 50);

Resolve the Configuration

Resolve the configuration and use it in your application:

const config = await resolver.resolve();
console.log(config);

Configuration Providers

Environment Variable Provider

The EnvConfigProvider reads configuration values from environment variables. You can specify a prefix to filter environment variables and provide custom variables for testing purposes.

import { EnvConfigProvider } from "stilla";

const envProvider = new EnvConfigProvider({
    prefix: "APP_",
    variables: {
        APP_KEY1: "value1",
        APP_KEY2: "42",
        APP_NESTED_KEY3: "true",
        APP_ARRAY_0_KEY4: "value2",
        APP_ARRAY_1_KEY4: "value3",
    },
});

File Provider

The FileConfigProvider reads configuration values from files. It supports multiple file formats, including JSON, YAML, TOML, and JSON5.

import { FileConfigProvider } from "stilla";

const fileProvider = new FileConfigProvider({
    basePath: "/path/to/config",
});

Files are loaded in the following order (latter files override earlier ones):

  • default.<ext>
  • <env>.<ext>
  • local.<ext>
  • local-<env>.<ext>

While in theory you can have the same file with different extensions present, the order in which they are loaded is not guaranteed, and you should refrain from doing so.

By default, only the json extension is supported by default. In order to enable support for other extensions, you must install a parser dependency for the ones you want to use:

  • YAML: yaml
  • TOML: smol-toml
  • JSON5: json5

Testing

Unit tests are provided to ensure the correctness of the configuration providers and the resolver. To run the tests, use the following command:

pnpm test

Contributing

Contributions are welcome! Please open an issue or a pull request if you have any suggestions or improvements.

License

This project is licensed under the BSD-2-Clause License.