Registry / devops / confidence

confidence

JSON →
library5.0.1jsnpmunverified

Confidence is a configuration management library that provides a structured document format and an API for serving dynamic configuration values. It builds upon standard JSON objects, introducing special `$`-prefixed keys for filtering values based on defined criteria, facilitating environment-specific configurations, A/B testing, and dynamic value selection. The current stable version is 5.0.1, which requires Node.js v12 or higher; older Node.js environments (pre-v12) must use version 4.x. The project is actively maintained, with releases primarily driven by bug fixes, feature enhancements, and Node.js compatibility updates. Its key differentiators include built-in support for environment variables, criteria-based filtering, value ranges for A/B testing, and metadata attachment, making it a robust solution for complex application configurations.

devopsserializationdata
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Confidence v5+ is ESM-only. For CommonJS, use v4 or earlier, or a bundler that handles ESM to CJS conversion.

import { Store } from 'confidence';

The class is named 'Store', not 'ConfidenceStore', despite being referred to as 'confidenceStore' in some documentation snippets (e.g., 'new confidenceStore').

import { Store } from 'confidence';

Demonstrates initializing a Confidence Store, retrieving configuration values with and without criteria, and showcases environment variable integration.

import { Store } from 'confidence'; const configDoc = { "key1": "abc", "key2": { "$filter": "env", "production": { "deeper": "production_value" }, "$default": { "$filter": "platform", "android": 0, "ios": 1, "$default": 2 } }, "key3": { "sub1": 123, "sub2": { "$filter": "xfactor", "yes": 6, "$default": 7 } }, "mysql": { "host": { "$env": "MYSQL_HOST" }, "port": { "$env": "MYSQL_PORT" }, "user": { "$env": "MYSQL_USER" } } }; const store = new Store(configDoc); // Simulate environment variables for demonstration process.env.MYSQL_HOST = process.env.MYSQL_HOST ?? 'localhost'; process.env.MYSQL_PORT = process.env.MYSQL_PORT ?? '3306'; process.env.MYSQL_USER = process.env.MYSQL_USER ?? 'testuser'; console.log('Without criteria:'); console.log(store.get('/')); const criteria = { "env": "production", "platform": "ios", "xfactor": "yes" }; console.log('\nWith criteria:'); console.log(store.get('/', criteria)); console.log('\nSpecific key with criteria:'); console.log(store.get('/key2/deeper', criteria)); console.log('\nEnvironment variable based config:'); console.log(store.get('/mysql'));
Debug
Known footguns
breakingConfidence v5.x drops support for Node.js versions older than v12. Applications running on Node.js v10 or earlier must remain on Confidence v4.x or upgrade their Node.js environment.
breakingConfidence v5.x is distributed as an ES Module (ESM) and no longer provides a CommonJS (CJS) entry point. Direct `require()` statements will fail in Node.js environments unless transpiled or using dynamic `import()`.
gotchaThe configuration document uses special `$`-prefixed keys (e.g., `$filter`, `$default`, `$env`) for directives. Attempting to use these prefixes for regular data keys will lead to unexpected behavior or errors as they are reserved for Confidence's internal logic.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources