@nestarc/feature-flag
DB-backed feature flags for NestJS + Prisma + PostgreSQL -- tenant-aware overrides, percentage rollouts, and zero external dependencies.
Features
- Database-backed -- flags stored in PostgreSQL via Prisma, no external service required
- Tenant / user / environment overrides -- granular control per tenant, user, or deployment environment
- Percentage rollouts -- deterministic hashing (murmurhash3) for consistent per-user bucketing
- Guard decorator --
@FeatureFlag()automatically gates routes and controllers - Bypass decorator --
@BypassFeatureFlag()exempts health checks and public endpoints - Programmatic evaluation --
isEnabled()andevaluateAll()for service-layer logic - Built-in caching -- configurable TTL with manual invalidation
- Event system -- optional integration with
@nestjs/event-emitterfor audit and observability - Testing utilities -- drop-in
TestFeatureFlagModulefor unit and integration tests
Installation
bash
npm install @nestarc/feature-flagPeer dependencies
bash
npm install @nestjs/common @nestjs/core @prisma/client rxjs reflect-metadataOptional
bash
# Required only if you enable emitEvents
npm install @nestjs/event-emitter