Add contributing guidelines, feature flag utilities, and route integrity tests
This commit is contained in:
23
frontend/src/config/featureFlags.ts
Normal file
23
frontend/src/config/featureFlags.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Feature flag utilities for the frontend.
|
||||
*
|
||||
* Feature flags are read from VITE_FEATURE_* environment variables.
|
||||
* When a flag is absent or set to "true", the feature is ENABLED (opt-out model).
|
||||
* Set a flag to "false" to disable a feature.
|
||||
*
|
||||
* Usage:
|
||||
* import { isFeatureEnabled } from '@/config/featureFlags';
|
||||
* if (isFeatureEnabled('EDITOR')) { ... }
|
||||
*/
|
||||
|
||||
type FeatureName = 'EDITOR' | 'OCR' | 'REMOVEBG';
|
||||
|
||||
/**
|
||||
* Check whether a feature is enabled.
|
||||
* Defaults to `true` if the env var is not set.
|
||||
*/
|
||||
export function isFeatureEnabled(feature: FeatureName): boolean {
|
||||
const value = import.meta.env[`VITE_FEATURE_${feature}`];
|
||||
if (value === undefined || value === '') return true; // enabled by default
|
||||
return value.toLowerCase() !== 'false';
|
||||
}
|
||||
Reference in New Issue
Block a user