1.1.8 • Published 9 days ago

cat-config v1.1.8

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
9 days ago

pipeline coverage

Install

yarn add cat-config

Example

// conf.json file
{
  "confA": "conf.json",
  "confB": "conf.json"
}
# conf.yaml file
confB: "conf.yaml"
confC: "conf.yaml"
import CatConfig from 'cat-config';

const CONF = CatConfig({
  confA: 'v_1',
  confB: 'v_2',
  confC: 'v_3'
})
  .env()
  .json()
  .yaml()
  .exec();

console.log(CONF);
/*
{
  foo: 'bar',
  confA: 'conf.json',
  confB: 'conf.yaml',
  confC: 'conf.yaml'
}
*/

set config from docker-compose.yml

# docker-compose.yml
version: '3.9'

services:
  node:
    image: nodejs
    environment:
      CONF: |
        keyA: value_A
        keyB: value_B
import CatConfig from 'cat-config';

const CONF = CatConfig({
  keyA: ''
  keyB: ''
})
  .loadEnv()
  .exec();

NODE_ENV

load config file with NODE_ENV environment \ if NODE_ENV not set default is dev

const CONF = CatConfig({})
  .yaml()
  .js()
  .json()

If NODE_ENV is not set cat-config will load file

  • conf.yaml
  • conf.dev.yaml
  • conf.js
  • conf.dev.js

If NODE_ENV is set to test cat-config will load file

  • conf.yaml
  • conf.test.yaml
  • conf.js
  • conf.test.js

you can set conf.dev.* in .gitignore file

Merge

CAT_CONFIG__SOMETING will convert to

{
  catConfig: {
    someting: ''
  }
}

Options

mainPath

directory store config file

filename

prefix of config file \ default is "conf"

freeze

use Object.freeze to freeze config \ default is true \ see Object.freeze()

Debug

debug with debug library

DEBUG=cat-config
1.1.8

9 days ago

1.1.7

10 days ago

1.1.5

11 days ago

1.1.1

15 days ago

1.1.0

15 days ago

1.1.4

15 days ago

1.1.3

15 days ago

1.1.2

15 days ago

1.0.7

21 days ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.0.1

10 months ago