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 🙏

© 2024 – Pkg Stats / Ryan Hefner

config-process

v0.0.2

Published

Simple light ts config lib with getters support

Downloads

5

Readme

process config

NPM Version Build Status Test Coverage

config-process organizes hierarchical configurations for your app configurations. Configure typescript projects, fullt support typescript interfaces.

It lets you define a set of process configuration parameters, and extend them for different environments (development, qa, staging, production, etc.).

It plays nicely with any deployment mechanisem (docker , k8s , env vars , etc.. ), details in motivation section.

#Features config-process comes with a basic implementation of configuration manager. The configuration manager asynchronously loads plugins, each plugin uses different methods of configuration loading.

This configuration manager:

  • Allows to use any built in or custom configuration plugins.
  • Allows to control the order of loading plugins.
  • Allows to control the hierarchy in which variables will be overidden.
  • Comes with a built in boolean/number/json getters.
  • Fully support asynchronous loading - perfect for fetching remote config from a remote server.
  • Comes with some strong default to enable strong ease of use.
  • Tiny with zero dependencies.
  • Fully supports dotenv files so it's hassle free to move from dotenv to config-process

Configuration load order ≠ hierarchy

Configuration load order can influence on if/which next configuration loader will be used. Configuration hierarchy influence on the order that the values will be merged into a single value.

NODE_ENV VS ENVIRONMENT

Some of the built-in plugins use NODE_ENV to determine the environment the code is running. The problem with NODE_ENV is that some libs may act defferntlly according to NODE_ENV value which may cause undesired results. Therefore, the built-in plugins first try to use ENVIRONMENT and only than use NODE_ENV. It's also possible to change this behavior to first load a custom key instead of ENVIRONMENT by setting envKey to any desired key.

It's encourged that all plugins made to use this approach.

Example:

  import { ProcessConfig } from 'config-process'
  
  const config = new ProcessConfig({
    envKey : 'YOU_CUSTOM_KEY'
  })

#Simple - Default usage By default the config-process will try to use plugins by the following order:

  • env
  • dotenv
  • fs

Which means that by default values will be determined by the following hierarchy:

  • fs
  • dotenv
  • fs
  REQUEST_TIMEOUT=100 node server.js
  const processConfig = require('config-process');

  processConfig.get<number>('REQUEST_TIMEOUT' , 'number')

#Motivation In Node.JS echo system there are a dozen of popular conifguration modules. The most standard modules in the echo system has at least one of the following problems:

  • Some depends on a file that needs to be switched during deployment, this requires some build specific logic to be applied as a result same image cannot be used to all environments
  • Some don't provide casting, as a result when a value is being set by the environments, as an environment variable, it will always be a String this will require the application to manually cast it every time consumed.
  • Some provides nesting in configuartion files, which makes it harder to be overidden by real environment variables.
  • Some are not customisable, allows only it's openion of usage.

License

MIT