This package has been deprecated

Author message:

Use @excsn/c5store

@exforte/c5store
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha3 • Public • Published

C5Store for NodeJS

C5Store is an all encompassing configuration store. The idea is to have one place to query and dump configuration, secrets and etc.

Read more about it: https://github.com/normano/c5store

Getting Started

To start using C5Store in yor NodeJS application.

  1. Install as a dependency
  • npm i @exforte/c5store
  • yarn add @exforte/c5store
  1. Import with

import {createC5Store, defaultConfigFiles, C5Store, C5StoreMgr} from "@exforte/c5store";

  1. Create a config folder with common.yaml

foo: bar

  1. Create the store

let [c5Store, c5StoreMgr] = await createC5Store(configFilePaths: Array<string>, logger: Logger, stats: StatsRecorder)

  1. Use the store

let data = c5Store.get("foo")

IMPORTANT: Look at the example folder for a implementation and how to use the C5FileValueProvider to get data from a file.

API

createC5Store(configFilePaths: Array, logger: Logger, stats: StatsRecorder)

  • Creates a 2-tuple containing C5Store and C5Store manager.

C5Store

  • get(keyPath: string)
    • Gets data immediately from the store
  • subscribe(keyPath: string, listener: ChangeListener)
    • Listens to changes to the given keyPath. keyPath can be any the entire path or ancestors. By listening to an ancestor, one will receive one change event even if two children change.

C5StoreMgr

  • setVProvider( name: string, vProvider: C5ValueProvider, refreshPeriodSec: number, )
    • Registers the value provider, immediately fetches all values it will provide and schedules periodic refreshes. refreshPeriodSec if 0 will not perform any scheduling.
  • stop()
    • Stops all of the scheduled refreshes.

Readme

Keywords

none

Package Sidebar

Install

npm i @exforte/c5store

Weekly Downloads

1

Version

1.0.0-alpha3

License

MPL-2.0

Unpacked Size

48 kB

Total Files

19

Last publish

Collaborators

  • exforte