Description
QuickLendX rolls out new endpoints (KYC tiers, dispute composer, bid ranking changes) but has no per-tenant flag. Today every API key sees the same routes regardless of stage. A simple sqlite-backed feature-flag service keyed by (api_key_id, flag) lets us roll out endpoints to a subset of customers without separate deployments. Distinct from the static OpenAPI versioning in #836.
Requirements and context
- Add
backend/src/services/featureFlagService.ts reading from a feature_flags table.
- Add middleware
backend/src/middleware/feature-flag.ts that 404s when a flag is off for the current API key.
- Provide admin endpoints to toggle flags.
- Document in
backend/docs/admin-monitoring.md.
Suggested execution
Create branch feature/per-tenant-feature-flags:
- Add migration
backend/src/migrations/v006_feature_flags.ts.
- Add
backend/src/services/featureFlagService.ts and backend/src/middleware/feature-flag.ts.
- Add admin route in
backend/src/routes/v1/admin.ts.
- Add
backend/src/tests/feature-flag.test.ts.
- Update
backend/docs/admin-monitoring.md.
Test and commit
Run npm test -- feature-flag. Cover: flag-on tenant sees endpoint, flag-off tenant 404s, default (no row) treats flag as off, admin toggle audited, cache invalidates on toggle. Confirm the flag check adds <1ms overhead.
Example commit message
feat: add per-tenant feature flag service for staged rollouts
Guidelines
- Minimum 95% test coverage
- Document flag administration in
backend/docs/admin-monitoring.md
- Timeframe: 96 hours
Description
QuickLendX rolls out new endpoints (KYC tiers, dispute composer, bid ranking changes) but has no per-tenant flag. Today every API key sees the same routes regardless of stage. A simple sqlite-backed feature-flag service keyed by
(api_key_id, flag)lets us roll out endpoints to a subset of customers without separate deployments. Distinct from the static OpenAPI versioning in #836.Requirements and context
backend/src/services/featureFlagService.tsreading from afeature_flagstable.backend/src/middleware/feature-flag.tsthat 404s when a flag is off for the current API key.backend/docs/admin-monitoring.md.Suggested execution
Create branch
feature/per-tenant-feature-flags:backend/src/migrations/v006_feature_flags.ts.backend/src/services/featureFlagService.tsandbackend/src/middleware/feature-flag.ts.backend/src/routes/v1/admin.ts.backend/src/tests/feature-flag.test.ts.backend/docs/admin-monitoring.md.Test and commit
Run
npm test -- feature-flag. Cover: flag-on tenant sees endpoint, flag-off tenant 404s, default (no row) treats flag as off, admin toggle audited, cache invalidates on toggle. Confirm the flag check adds <1ms overhead.Example commit message
feat: add per-tenant feature flag service for staged rolloutsGuidelines
backend/docs/admin-monitoring.md