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-stack

v1.0.0

Published

Features -------------------------- - Parses open api v3 specs in **JSON** or **YAML** format - load open api v3 from **file**, **url**, **json string**, **plain javascript object** - Resolves all `$ref` pointers, including external files and URLs - Cons

Downloads

2

Readme

config-stack

keep your configurations organized and stacked

Why Config Stack ?

When building a modern application, you don’t want to worry about configuration file formats; you want to focus on building awesome software. config-stack is here to help with that.

Features

  • Find, load, and parse a configuration file in JSON, TOML, YAML, HJSON, JSON5.
  • Provide a mechanism to set default values for your different configuration options.
  • Working with environment variables (This enables 12 factor applications)
  • Working with different deployment environments (development, qa, staging, production, etc.).
  • Find, load, and parse a command line
  • Support both typescript and javascript
  • inject configuration using typescript decorator
  • Type safety
  • Transform configuration value to a specified type
  • zero-dependency module

Example

  • typescript - load from file
  import * as configStack from 'config-stack'
  configStack.loadFile('./config.toml','test')
  // or to default environment
  configStack.loadFile('/config.toml')
  configStack.getString('key') // or any other function
  • javascript - load from file
  const configStack = require('config-stack')
  configStack.loadFile('./config.toml','test')
  // or to default environment
  configStack.loadFile('/config.toml')
  configStack.getString('key') // or any other function
  • typescript - bind all environment variables
  import * as configStack from 'config-stack'
  configStack.automaticEnv(); // ENV will be in lowercase "env"
  console.log(configStack.getString('env'));
  • javascript - bind all environment variables
  const configStack = require('config-stack')
  configStack.automaticEnv(); // ENV will be in lowercase "env"
  console.log(configStack.getString('env'));
  • typescript - bind specific environment variable
  import * as configStack from 'config-stack'
  configStack.bindEnv('env','development'); 
  console.log(configStack.getString('env','development'));
  • javascript - bind specific environment variable
  const configStack = require('config-stack')
  configStack.bindEnv('env','development'); 
  console.log(configStack.getString('env','development'));
  • typescript - set target environment
  import * as configStack from 'config-stack'
  configStack.set('key',2,'production')
  configStack.set('key',1,'test')
  configStack.setTragetEnv('test')
  // or from default environment
  console.log(configStack.get('key')); // print 2
  • javascript - set target environment
  const configStack = require('config-stack')
  configStack.set('key',2,'production')
  configStack.set('key',1,'test')
  configStack.setTragetEnv('test')
  // or from default environment
  console.log(configStack.get('key')); // print 2
  • typescript - bind object
  import * as configStack from 'config-stack'
  const obj = {
     nested: {
       key: "1"
    }
  };
  console.log(configStack.getObject('nested')) // {key: "1"}
  console.log(configStack.getNumber('nested.key')) // 1 
  console.log(configStack.getString('nested.key')) // '1' 
  • javascript - bind object
  const configStack = require('config-stack')
  const obj = {
     nested: {
       key: "1"
    }
  };
  console.log(configStack.getObject('nested')) // {key: "1"}
  console.log(configStack.getNumber('nested.key')) // 1 
  console.log(configStack.getString('nested.key')) // '1' 
  • typescript - working with command line
  import * as configStack from 'config-stack'
  const flag = configStack.Flag('usage','environment<test|qa|etc..>');
  flag.set(
    {
    	name: 'name',
        usage: 'user name',
    	
    }
  );
  flag.set(
    {
    	name: 'birthday',
        usage: 'user birthday',
        alias: 'b'
    	
    }
  );
  flag.set(
    {
    	name: 'student',
        usage: 'is user student',
        boolean: true,
        default: false
    	
    }
  );
  flag.parse();
  configStack.bind(flag);
  console.log(`user name ${configStack.getString('name')}`);
  console.log(`user birthday ${configStack.getDate('birthday')}`);
  console.log(`user student ${configStack.getBoolean('student')}`);
  • javascript - working with command line
  const configStack = require('config-stack')
  const flag = configStack.Flag('usage','environment<test|qa|etc..>');
  flag.set(
    {
    	name: 'name',
        usage: 'user name',
    	
    }
  );
  flag.set(
    {
    	name: 'birthday',
        usage: 'user birthday',
        alias: 'b'
    	
    }
  );
  flag.set(
    {
    	name: 'student',
        usage: 'is user student',
        boolean: true,
        default: false
    	
    }
  );
  flag.parse();
  configStack.bind(flag);
  console.log(`user name ${configStack.getString('name')}`);
  console.log(`user birthday ${configStack.getDate('birthday')}`);
  console.log(`user student ${configStack.getBoolean('student')}`);
./example.js --help 
./example.js -b 01-12-2003 --name john --student
  • typescript - working with custom binder
import * as configStack from 'config-stack'
class CustomBinder implements configStack.Binder {
  bind(set: configStack.SetFunction){
   set('key','value','test')
   set('key','value')
  }
}
bind(new Custominder())
  • javascript - working with custom binder
const configStack = require('config-stack')
class CustomBinder {
  bind(set){
   set('key','value','test')
   set('key','value')
  }
}
configStack.bind(new Custominder())
  • typescript - decorators
import * as configStack from 'config-stack'
class TestClass {
 @configStack.GetString('name')
 public name: string;

 @configStack.Get('any')
 public _any: any;

 @configStack.GetNumber('age')
 public age: number;

 @configStack.GetBoolean('valid')
 public isValid: boolean;

 @configStack.GetRegex('regex')
 public regex: RegExp;

 @configStack.GetDate('date')
 public date: Date;

 @configStack.GetObject('obj')
 public Object: Object;

 @configStack.GetArray('any_array')
 public array: any[];

 @configStack.GetBooleanArray('boolean_array')
 public boolean_array: boolean[];

 @configStack.GetStringArray('string_array')
 public string_array: string[];

 @configStack.GetNumberArray('number_array')
 public number_array: number[];
}

Installation

Install using npm:

npm install config-stack

Documentation

Roadmap

  • support remote config like etcd
  • laze automatic env
  • load config-stack schema
  • environment variables prefix

Contributing

I welcome any contributions, features, enhancements, and bug-fixes. File an issue on GitHub and submit a pull request.

License

Type config-stack is 100% free and open-source, under the MIT license. Use it however you want.