1.2.2 • Published 8 months ago

cat-config v1.2.2

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
8 months 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.2.2

8 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.1.9

8 months ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.5

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.7

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago