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

@alarife/configuration

v0.7.0

Published

Centralized configuration system for Alarife applications.

Downloads

143

Readme

@alarife/configuration - Centralized configuration system for Alarife applications.

NPM Version License TypeScript

Centralized configuration for architect, centralizes argv, env, secure-env.

📋 Table of Contents

🚀 Installation

npm install @alarife/configuration --save-dev

📦 Basic Usage

This package provides a small, pluggable configuration system. Create a Configuration instance, register one or more loaders (objects that extend ConfigurationLoader) and call load(). Loaders with higher priority run later and will override values set by earlier loaders.

Example (TypeScript):

import { Configuration, ConfigurationLoader } from '@alarife/configuration';

class DefaultLoader extends ConfigurationLoader {
	public priority = 1;
	private defaults = [
		{ argv: 'port', env: 'PORT', value: 3000 },
		{ argv: 'debug', env: 'DEBUG_MODE', value: false },
	];

	load(state) {
		for (const p of this.defaults) {
			state.setProperty(p);
		}
	}
}

class EnvLoader extends ConfigurationLoader {
	public priority = 2;
	load(state) {
		if (process.env.PORT) {
			state.setProperty({ argv: 'port', env: 'PORT', value: Number(process.env.PORT) });
		}
		if (typeof process.env.DEBUG_MODE !== 'undefined') {
			state.setProperty({ argv: 'debug', env: 'DEBUG_MODE', value: process.env.DEBUG_MODE === 'true' });
		}
	}
}

const config = new Configuration();
config.addLoader(new DefaultLoader());
config.addLoader(new EnvLoader());
config.load();

console.log('port:', config.getState().getProperty('port'));
console.log('debug:', config.getState().getProperty('debug'));

📖 Detailed API

ConfigurationLoader

Abstract base class for configuration loaders. Implementors provide a numeric priority and a load(state) method.

abstract class ConfigurationLoader {
	public abstract priority: number;
	abstract load(state: ConfigurationState): void;
}

| Method / Property | Description | |---|---| | priority: number | Numeric priority. Higher number = higher precedence. Loaders are sorted ascending and executed in that order, so loaders with larger priority values run later and can override earlier values. | | load(state: ConfigurationState): void | Abstract method invoked during Configuration.load(). Implementations should call state.setProperty(...) to apply properties. |


Configuration

High-level coordinator that registers loaders and applies them against a single ConfigurationState.

const config = new Configuration(...loaders?: ConfigurationLoader[]);

| Method | Description | |---|---| | addLoader(loader: ConfigurationLoader): void | Register a loader instance to be executed when load() is called. | | load(): void | Sorts registered loaders by priority (ascending) and invokes each loader's load(state) method. Loaders executed later may override earlier values. | | getState(): ConfigurationState | Returns the internal ConfigurationState instance for direct inspection or manipulation. |


ConfigurationState

In-memory storage for configuration properties and their aliases.

const state = new ConfigurationState();

| Method | Description | |---|---| | getProperty(key: string): any | Return the value of the property that contains key in its alias list, or undefined if not present. | | setProperty(source: SourceProperty): void | Add or update a property. Rules: each alias in source.key must be unique across all properties (otherwise a Duplicate key error is thrown). When updating an existing property you may add new aliases only if the incoming source.key includes all existing aliases — omitting existing aliases while adding new ones will throw an error. | | forEach(callback: (property: SourceProperty) => void): void | Iterate over all stored properties. | | toArray(): SourceProperty[] | Allows retrieving the stored parameter list | | export(): string | Serialize the current state to a JSON string. | | import(data: string): void | Parse JSON and import properties via setProperty. Throws an error on parse failure or invalid updates. |


SourceProperty

Interface describing a property and its aliases.

interface SourceProperty {
	argv: string;
	shortArgv?: string;
	env: string;
	value: any;
}

| Property | Description | |---|---| | argv: string | Alias for the command-line argument. | | shortArgv?: string | Optional alias for a shorter version of the command-line argument. | | env: string | Alias for the environment variable. | | value: any | The property's value (string, number, boolean, object, ...). |


Notes:

  • Error behavior: the library throws Error when encountering duplicate keys, invalid alias updates, or when import() receives invalid JSON.
  • Recommended priority ordering: 1 = defaults, 2 = environment variables, 3 = command-line arguments (higher number wins).

CtxStore

This service is used as a bridge at runtime after configuration in the main CLI thread.

/** Service use Manual */
const store = new CtxStore();

/** Service use automatic */
import { ctxStore } from '@alarife/configuration';

Notes:

  • This service is an extension of ConfigurationState.
  • The instantiated form of this functionality accesses the CONFIGURATION_STATE environment variable

📄 License

This project is licensed under Apache-2.0. See the LICENSE file for details.


Built with ❤️ by Soria Garcia, Jose Eduardo

🌍 Product developed in Andalucia, España 🇪🇸

Part of the Alarife ecosystem