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

v1.0.2

Published

Config manager that helps you manage the environment vars for your different apps across all of your deployment environments. Typical environments might include `local`, `dev`, `test`, `stage`, and `prod`, although you can have as many as you want, and

Downloads

628

Readme

config-manager

Config manager that helps you manage the environment vars for your different apps across all of your deployment environments. Typical environments might include local, dev, test, stage, and prod, although you can have as many as you want, and call them whatever you like. config-manager also supports having a default.json file which contains global config values shared across apps.

How?

First, install it in your project's directory:

npm install config-manager

Then add this line to your app's configuration:

var configManager = require('config-manager')

Finally, initialize the manager with the base path of your config files, the target env, and the name of your app:

var conf = configManager.init([BASE_PATH_TO_CONFIG_FILES], [TARGET_ENV], [NAME_OF_APP], function(conf){
  //At this point the conf object has the resolved env vars ready for use
});

There is also a synchronous version if you want:

var conf = configManager.initSync([BASE_PATH_TO_CONFIG_FILES], [TARGET_ENV], [NAME_OF_APP]);

Config Files

Example config files can be found in the test/files folder. The basic layout of these files is as follows:

{
  "default": {
    "env1" : "value1"
  },
  "dev" : {
    "env1" : "value1OverrideDefaultDev",
    "devOnly1" : "value1"
  },
  "test" : {},
  "prod" : {
    "env1" : "value1OverrideDefaultProd"
  },
  "myMadeUpEnv" : {
    "env" : "mymadeupvalue"
  }
}

The default.json file is used for setting global config values that apply to all of your apps and can also be used to globally target specific deployment environments.

Individual apps can include an [appname].json file that will be used to override the values found in the default.json file with values specific to a particular app.

Env Var Value Resolution

Values for an app's environment variables are derived using the following resolution chain:

  • default section of the default.json file
  • override with default section of the [appname].json file
  • override with [target env] section of the default.json file
  • override with [target env] section of the [appname].json file

The default.json file can be used to set global configuration values that apply to all of our apps. Based on where in the file you add the values, you can target every app in every environment (by placing the value in the default section), or you can target every production app for example (by placing the value in the prod section of the file).

Configuration that applies only to one app should be placed in the json file corresponding to that app. The same rules apply for how values affect the different environments. The default section will apply to all instances of the app and the other sections will only apply to those specific deployment environments.