Skip to content
This repository has been archived by the owner on Jul 14, 2019. It is now read-only.
/ sweet-config Public archive

Load configuration, support process env, default value, file module configuration.

Notifications You must be signed in to change notification settings

sunfuze/sweet-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Sweet config load file/directory configuration for you, it handle env configuration in an fixed way.

Quick Start

Only support js/json file formats Install in your app directory

npm install sweet-config
mkdir config
vi config/application.json
mkdir config/env
vi config/env/development.js
vi config/env/production
// application.json
{
  "keys": ["abc", 'def']
}
// env/development.js
module.exports = {
  database: {
    host: 'localhost'
  }
}
// env/production
module.exports = {
  database: {
    host: '127.0.0.1'
  }
}
const config = require('sweet-config')
config.load() // if not give directory or file path, will load `config` directory in project root
config.get('application.keys') // should equals to ['abc', 'def']
// sweet config will load env configuration in root
config.get('database') // should equals to {host: '127.0.0.1'} when NODE_ENV=production

About

Load configuration, support process env, default value, file module configuration.

Resources

Stars

Watchers

Forks

Packages

No packages published