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

appfig

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appfig

An extremely useful configuration loader.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

appfig

Combines nconf, recurpolate, and declarative JSON "extends" syntax to create an extremely useful configuration loader.

Build Status Coverage Status

Usage

All the value packed into appfig is demonstrated in ./example, which is summarized for your reading below. appfig is compatible with Node 8+. Enjoy.

config/default.json

{
  "port": 3000,
  "logLevel": "debug",
  "services": {
    "users": "http://${host}/users"
  }
}

config/development.json

{
  "extends": "default",
  "host": "dev.example.com"
}

config/production.json

{
  "extends": "default",
  "port": 3001,
  "logLevel": "info",
  "host": "www.example.com"
}

index.js

process.env.APP_ENV = process.env.APP_ENV || 'development';

const { APP_ENV } =  process.env;

const config = require('appfig')(__dirname + `/config/${APP_ENV}.json`);

console.log(config.get('port'));
console.log(config.get('logLevel'));
console.log(config.get('services:users'));

Starting your application with development configuration

$ node index.js

3000
trace
http://dev.example.com/users

Starting your application with production configuration

$ APP_ENV=production node index.js

3001
info
http://www.example.com/users

Use it

appfig is released under the MIT License.

Keywords

FAQs

Package last updated on 30 Jun 2018

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