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

@geek/config

v1.0.5

Published

Geek Configuration Manager for Node.js - The complete solution for managing config settings for your Node.js application

Downloads

79

Readme

@geek/config

@geek/config Dependabot Status

Geek Configuration Manager for Node.js - The complete solution for managing config settings for your Node.js application

🚀 Getting Started

Install

Install @geek/config

npm install @geek/config

Usage

const Config = require('@geek/config');

// single profile
const config1 = new Config({
	cwd:       __dirname,
	name:      'myapp',
	profile:   'dev',
	overrides: { property2: 'override-value'  },
	defaults:  { property9: 'default-value'  },
});

// multiple profiles
const config2 = new Config({
	cwd:       __dirname,
	name:      'myapp',
	profiles:  [ 'dev', 'ios' ],
	overrides: { property2: 'override-value'  },
	defaults:  { property9: 'default-value'  },
});

Priority of config files

| priority | source | example | location | |:-: |:-: |:-: |:-: | | 1. | process.env | MYAPP_PROPERTY1="environment-value" | environment variable | | 2. | overrides | { "property1": "override-value" } | parameter: overrides | | 4. | files | ['~/.titanium/config.json', '~/.tn.json'] | parameter: files | | 5. | user profile config file | myapp.dev.user.json | project directory | | 6. | user config file | myapp.user.json | project directory | | 7. | project profile config file | myapp.dev.project.json | project directory | | 8. | project config file | myapp.project.json | project directory | | 9. | global profile config file | myapp.dev.global.json | home config directory | | 10. | global config file | myapp.global.json | home config directory | | 11. | system config file | myapp.system.json | home config directory | | 12. | default values | { "property1": "default-value" } | parameter: defaults |

Examples

NOTE: Currently only the file extension .json is supported. Support for more file extensions will be added very soon.

This following part of the documentation has not been updated yet to reflect support for profiles but it will be updated soon.

Parameters: name

cost Config = require('@geek/config');
const config = new Config({ name: 'myapp' });
  • process.env variables (if exists)

Loaded objects fromm all the manually entered filenames:

  • files (from parameter )

One of the following:

  • myapp.user.json5 (if exists)
  • myapp.user.yaml (if exists)
  • myapp.user.yml (if exists)
  • myapp.user.json (if exists)

One of the following:

  • myapp.project.json5 (if exists)
  • myapp.project.yaml (if exists)
  • myapp.project.yml (if exists)
  • myapp.project.json (if exists)

One of the following:

  • ~/.myapp/global.json5 (if exists)
  • ~/.myapp/global.yaml (if exists)
  • ~/.myapp/global.yml (if exists)
  • ~/.myapp/global.json (if exists)

One of the following:

  • ~/.myapp/system.json5 (if exists)
  • ~/.myapp/system.yaml (if exists)
  • ~/.myapp/system.yml (if exists)
  • ~/.myapp/system.json (if exists)

Parameters: name, overrides, defaults

cost Config = require('@geek/config');
const config = new Config({ name: 'myapp', overrides: { variable2: 'overrides' }, defaults: variable9: 'defaults' });
  • process.env variables (if exists)
  • overrides (from parameter)

Loaded objects fromm all the manually entered filenames:

  • files (from parameter )

One of the following:

  • myapp.user.json5 (if exists)
  • myapp.user.yaml (if exists)
  • myapp.user.yml (if exists)
  • myapp.user.json (if exists)

One of the following:

  • myapp.project.json5 (if exists)
  • myapp.project.yaml (if exists)
  • myapp.project.yml (if exists)
  • myapp.project.json (if exists)

One of the following:

  • ~/.myapp/global.json5 (if exists)
  • ~/.myapp/global.yaml (if exists)
  • ~/.myapp/global.yml (if exists)
  • ~/.myapp/global.json (if exists)

One of the following:

  • ~/.myapp/system.json5 (if exists)
  • ~/.myapp/system.yaml (if exists)
  • ~/.myapp/system.yml (if exists)
  • ~/.myapp/system.json (if exists)

default values

  • defaults (from parameter)

No parameters are passed in

  • process.env
  • manual overrides
  • myapp.user.json
  • myapp.project.json
  • myapp.global.json
  • default values

if passed in environment only: --profile dev

  • process.env
  • manual overrides
  • myapp.dev.user.json
  • myapp.user.json
  • myapp.dev.project.json
  • myapp.project.json
  • myapp.dev.global.json
  • myapp.global.json
  • default values

if passed in: --local-only

  • process.env
  • manual overrides
  • myapp.dev.user.json
  • myapp.user.json
  • myapp.dev.project.json
  • myapp.project.json
  • default values

if passed in specific config file: --config mytest.json (with no environment specified)

  • process.env
  • manual overrides
  • mytest.json
  • myapp.user.json
  • myapp.project.json
  • myapp.global.json
  • default values

if passed in specific config file: --config mytest.json --profile dev

  • process.env
  • manual overrides
  • mytest.json
  • myapp.dev.user.json
  • myapp.user.json
  • myapp.dev.project.json
  • myapp.project.json
  • myapp.dev.global.json
  • myapp.global.json
  • default values

if passed in: --only mytest.json

  • process.env
  • manual overrides
  • mytest.json
  • default values

📚Learn More

📣 Feedback

Have an idea or a comment? Join in the conversation here!