@cnwangjie/conf

Lightweight Node.js configuration with enough feature.

Usage no npm install needed!

<script type="module">
  import cnwangjieConf from 'https://cdn.skypack.dev/@cnwangjie/conf';
</script>

README

config.js

Build Status Coverage Status

Lightweight Node.js configuration with enough feature.

Installation

yarn add @cnwangjie/conf

Usage

const conf = require('@cnwangjie/conf')

// load config file in bootstrap
conf().load('config.json')
// you can use absolute path or path relative with current path

// besides, you can load any type file of JS, YAML, TOML, ENV and you just need
// install corresponding module

// then you can get the config in every file by require config.js
conf('server.port')
conf().get('server.port')
conf.server.port
// you can use any type of style above

// even you can set separator you like by following way
conf().separator = ':'
conf('server:port')

You need to install corresponding module if you want to use other suffix config file.

suffix module
.yml js-yaml
.yaml js-yaml
.env dotenv
.toml toml