Feature/feature flag system#1051
Open
sweetesty wants to merge 4 commits into
Open
Conversation
…ard with 60s memory caching and neobrutalist Recharts charts
Implements Shelterflex#953. Adds a dedicated rent-to-own calculator page at /calculator/rent-to-own with real-time equity accumulation chart, plan comparison card (vs. standard renting), and edge-case handling for budgets too low to reach ownership. Links added to the main payment calculator (tab) and property detail pages (secondary CTA). Pure frontend — no API calls; all maths in lib/rentToOwnCalc.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements Shelterflex#978. Introduces a config-file-backed feature flag system for both backend and frontend with no external dependencies. Backend: - backend/src/config/featureFlags.ts — single typed source of truth for all flags (STAKING_ENABLED, INSPECTOR_DASHBOARD_ENABLED, RENT_TO_OWN_ENABLED, ADVANCED_WALLET_OPS_ENABLED, BACKEND_HEALTH_INDICATOR_ENABLED) - backend/src/services/featureFlags.ts — isEnabled() with FEATURE_FLAG_<NAME>=true env override support; getAllFlags() snapshot - backend/src/middleware/requireFlag.ts — requireFlag('FLAG') Express middleware; returns 403 when flag is off - backend/src/routes/featureFlags.ts — GET /api/config/feature-flags; auth-aware (admin > authenticated > guest flag subsets) - Wired requireFlag onto /api/staking and /api/inspector routes; /api/config/feature-flags mounted in app.ts Frontend: - frontend/config/featureFlags.ts — static defaults used during SSR before the client fetch resolves - frontend/lib/featureFlags.ts — FeatureFlagProvider (React context, fetches from /api/config/feature-flags on mount) + useFeatureFlag() hook; falls back to static defaults on error or during SSR - Wired FeatureFlagProvider into root layout Migrations (3 existing ad-hoc guards replaced): - tenant/page.tsx: featureFlags.enableExperimentalStaking → useFeatureFlag('STAKING_ENABLED') - BackendHealthCompact.tsx: NEXT_PUBLIC_SHOW_BACKEND_HEALTH env check → useFeatureFlag('BACKEND_HEALTH_INDICATOR_ENABLED') - /api/staking + /api/inspector: manual checks → requireFlag() middleware Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@sweetesty is attempting to deploy a commit to the pope-h's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@sweetesty Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #978
This PR builds a lightweight, config-file-backed feature flag system for both the backend and frontend with no external service dependency.
Backend
backend/src/config/featureFlags.ts— single source of truthFeatureFlagConfigrecord defining all flags with default values andsensitiveclassificationSCREAMING_SNAKE_CASEbackend/src/services/featureFlags.tsisEnabled(flag: string, context?: { userId?, role? }): boolean— synchronous for config-backed flags; reads defaults from config, appliesFEATURE_FLAG_<NAME>=true/falseenv overrides, then applies user/role targeting if context is providedFEATURE_FLAG_*env overrides take precedence over config defaults — works correctly in test and CI environmentsGET /api/config/feature-flagssensitive: trueflags for guests and tenants; admins receive the full flag setrequireFlag(flag: string)middlewareisEnabled()and returns403if the flag is offFrontend
frontend/config/featureFlags.ts— static SSR fallbacksfrontend/lib/featureFlags.tsxFeatureFlagProvider— fetches flags from/api/config/feature-flagson app load; stores result in React context; falls back to static defaults on fetch failureuseFeatureFlag(flag: string): boolean— reads from context; returns static default during SSR/hydrationMigration — 3 existing ad-hoc guards replaced
INSPECTOR_DASHBOARD_ENABLEDenv check →useFeatureFlag('INSPECTOR_DASHBOARD_ENABLED')requireFlag('STAKING_ENABLED')useFeatureFlag('MOCK_DATA_ENABLED')Acceptance criteria met:
isEnabledsynchronous for config-backed flagsFEATURE_FLAG_*env overrides work in test and CI