Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@geek/config

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geek/config

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

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-28.57%
Maintainers
2
Weekly downloads
 
Created
Source

@geek/config

@geek/config

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

prioritysourceexamplelocation
1.process.envMYAPP_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 filemyapp.dev.user.jsonproject directory
6.user config filemyapp.user.jsonproject directory
7.project profile config filemyapp.dev.project.jsonproject directory
8.project config filemyapp.project.jsonproject directory
9.global profile config filemyapp.dev.global.jsonhome config directory
10.global config filemyapp.global.jsonhome config directory
11.system config filemyapp.system.jsonhome 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.

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!

Keywords

FAQs

Package last updated on 02 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc