3.0.3 • Published 3 years ago

liveconfig v3.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

LiveConfig

Read/inject all json or yaml configs under specific directory, and keep runtime updating

NPM version

Install

$ npm install liveconfig -S

Usage

/*
 * there are 2 files in configDir:
 * user.json: {name: 'hans'}
 * system.yaml: domain: 'b.cc'
 */
let config = liveconfig(configDir)
console.log(config.user.name) //'hans'
console.log(config.system.domain) //'b.cc'
// update system.yaml file with new content: domain: a.cc
console.log(config.system.domain) //'a.cc'

// if you want to catch the event, pass me the event emittor
let eventEmitter = new require('events').EventEmitter(),
    config = liveconfig(myDir, eventEmitter)

eventEmitter.on('config.error', filename => {
    console.log(`failed to read config: ${filename}`)
})

// if you want to stop config file watching, emit a "stop" event
// eventEmitter.emit('config.stop')
3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

10 years ago