@rollercoders/flagforge-node
v0.1.0
Published
Node.js client for FlagForge feature flagging
Readme
flagforge-node
Node.js client for FlagForge feature flags. Read-only, zero dependencies, uses native fetch (Node 18+).
Installation
npm install flagforge-nodeUsage
import { FlagForgeClient } from 'flagforge-node';
const client = new FlagForgeClient({
host: 'https://flagforge.myapp.com',
apiKey: 'ff_xxxx',
timeout: 5000, // ms, optional — default: 5000
});
// Single flag — throws FlagForgeError on error
const enabled = await client.isEnabled('new-dashboard', {
userId: 'user-123',
attributes: { plan: 'premium' },
});
// Single flag — returns false on error (no exception)
const safe = await client.isEnabledSafe('new-dashboard', { userId: 'user-123' });
// Subset of flags
const results = await client.evaluateMany(['flag-a', 'flag-b'], { userId: 'user-123' });
// { 'flag-a': true, 'flag-b': false }
// All flags for the environment
const all = await client.evaluateAll({ userId: 'user-123' });Error Handling
All methods except isEnabledSafe throw FlagForgeError on:
- Network errors
- Non-2xx HTTP responses
- Invalid JSON responses
- Timeout
import { FlagForgeError } from 'flagforge-node';
try {
const enabled = await client.isEnabled('my-flag');
} catch (err) {
if (err instanceof FlagForgeError) {
console.error('Flag evaluation failed:', err.message);
}
}Requirements
- Node.js 18+
- FlagForge server with
POST /api/evaluate/allendpoint
