@quanticjs/feature-flags
v8.4.1
Published
Feature flag integration for quanticjs — Unleash-backed pipeline behavior
Downloads
1,737
Readme
@quanticjs/feature-flags
Unleash-backed @FeatureFlag pipeline behavior.
Configuration
QuanticFeatureFlagsModule.forRoot(options) forwards UnleashModuleOptions to the Unleash client:
QuanticFeatureFlagsModule.forRoot({
url: 'https://unleash.example.com/api', // or UNLEASH_URL
appName: 'my-app', // or UNLEASH_APP_NAME; default 'quanticjs-app'
customHeaders: { Authorization: token }, // or UNLEASH_API_TOKEN
refreshInterval: 10000,
disableMetrics: false,
environment: 'production',
// Last-known-good resilience:
bootstrap: { filePath: '/etc/flags/bootstrap.json' },
backupPath: '/var/lib/unleash',
// storageProvider: customStore,
});Production fail-fast: with NODE_ENV=production and the default insecure token (*:*.unleash-insecure-api-token) or a http://localhost URL, forRoot() throws at boot. Outside production it logs a single warning. Note the check keys on NODE_ENV === 'production' — ops must set it.
The client has 'error' and 'warn' listeners attached before forRoot() returns, so an Unleash outage cannot crash the process via an unhandled EventEmitter 'error'.
Outage semantics — choose a fallback per flag
When Unleash is unreachable and no bootstrap/backup exists, every isEnabled() returns false, so @FeatureFlag('x') with the default fallback: 'throw' returns Result.failure(Forbidden) for ALL guarded commands — i.e. fail-closed.
'throw'(default) — kill-switch semantics: a provider outage disables the feature. Correct for risky features.'skip'/'default'— the command still executes: correct for launched features where a provider outage must not take the feature down.- Additionally set
bootstrapand/orbackupPathso restarts during an outage evaluate from last-known-good values instead of all-false.
