0.1.0 • Published 2d ago
@flagsman/openfeature-server
Licence
MIT
Version
0.1.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0
@flagsman/openfeature-server
An OpenFeature server provider for Flagsman. Use Flagsman feature flags through the vendor-neutral OpenFeature API — so your app code has zero Flagsman-specific coupling and you can adopt (or leave) any provider without touching call sites.
It wraps an already-configured Flagsman server client (which streams the ruleset and evaluates in-process), so decisions stay byte-identical with every other Flagsman SDK.
Install
npm i @flagsman/openfeature-server @openfeature/server-sdk @flagsman/sdk-node
Usage
import { OpenFeature } from "@openfeature/server-sdk";
import { FlagsmanClient } from "@flagsman/sdk-node";
import { FlagsmanProvider } from "@flagsman/openfeature-server";
const fm = new FlagsmanClient({ serverKey: process.env.FLAGSMAN_SERVER_KEY! });
await fm.start(); // stream the ruleset
await OpenFeature.setProviderAndWait(new FlagsmanProvider(fm));
const client = OpenFeature.getClient();
const enabled = await client.getBooleanValue("new-checkout", false, {
targetingKey: userId,
country: "US",
plan: "pro",
});
Mapping
| OpenFeature | Flagsman |
|---|---|
targetingKey |
evaluation subject (sticky bucketing key) |
country / server / project |
the matching Flagsman context fields |
| any other context attribute | attrs.* (used by targeting rules) |
reason |
TARGETING_MATCH (target/rule/override), SPLIT (rollout), STATIC (default), DISABLED (off/killed/gate/prereq) |
| type mismatch | returns the default value with errorCode: TYPE_MISMATCH |
Boolean evaluations map to the flag's on/off state; string/number/object evaluations return the flag's served typed value.