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

Latest commit

 

History

History
49 lines (42 loc) · 977 Bytes

README.md

File metadata and controls

49 lines (42 loc) · 977 Bytes

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