confhub-node
v0.1.3
Published
Abstraction for using confhub within Node.js
Downloads
18
Readme
🔧 confhub-node
Node.js/TS wrapper around confhub.
Confhub handles the configuration, confhub-node makes it easy to work with confhub from within a Node.js application. It provides access to config in an intuitive and type-safe way.
Install
- Download confhub, compile it, and make sure it is in $PATH.
- Install confhub-node using
npm install confhub-node
Use
Define configuration structure in
Conf.ts:export type Conf = { a: string, b: boolean, c: number, d: { something: Array<string>, num: number } }Create configuration instance using
Conf.tsas declaration (more details on confhub page)confhub configure Conf.tsAccess configuration from your Node.js application
app.ts:import { Conf } from "./Conf.js"; import { Confhub } from 'confhub-node'; // replace confName below with name you've given to your configuration in step 2 const conf = new Confhub<Conf>('confName'); // return entire configuration object const entireConf = await conf.query(); // or query configuration by path // const value = await conf.query('b'); // boolean // const value = await conf.query('d'); // { something: Array<string>, num: number } // const value = await conf.query('d.something'); // Array<string>
