veza/apps/web/src/config/features.ts
senke e11984898d chore: consolidate CI, E2E, backend and frontend updates
- CI: workflows updates (cd, ci), remove playwright.yml
- E2E: global-setup, auth/playlists/profile specs
- Remove playwright-report and test-results artifacts from tracking
- Backend: auth, handlers, services, workers, migrations
- Frontend: components, features, vite config
- Add e2e-results.json to gitignore
- Docs: REMEDIATION_PROGRESS, audit archive
- Rust: chat-server, stream-server updates
2026-02-17 16:43:21 +01:00

98 lines
2.5 KiB
TypeScript

/**
* Feature Flags Configuration
*
* Controls which features are enabled/disabled for MVP.
* Features marked as false are not yet implemented in the backend.
*
* All flags can be overridden via VITE_FEATURE_* env vars (see .env.example).
* Feature status is documented in docs/FEATURE_STATUS.md
*/
function parseFeatureEnv(value: string | undefined, defaultValue: boolean): boolean {
if (value === undefined || value === '') return defaultValue;
const v = value.toLowerCase().trim();
return v === 'true' || v === '1' || v === 'yes';
}
export const FEATURES = {
/**
* Two-Factor Authentication
* Backend endpoints: /auth/2fa/setup, /auth/2fa/verify, /auth/2fa/disable, /auth/2fa/status
*/
TWO_FACTOR_AUTH: parseFeatureEnv(
import.meta.env.VITE_FEATURE_TWO_FACTOR_AUTH,
true,
),
/**
* Playlist Collaboration Features
* Backend endpoints: /playlists/:id/collaborators (GET, POST, PUT, DELETE)
*/
PLAYLIST_COLLABORATION: parseFeatureEnv(
import.meta.env.VITE_FEATURE_PLAYLIST_COLLABORATION,
true,
),
PLAYLIST_SEARCH: parseFeatureEnv(
import.meta.env.VITE_FEATURE_PLAYLIST_SEARCH,
true,
),
PLAYLIST_SHARE: parseFeatureEnv(
import.meta.env.VITE_FEATURE_PLAYLIST_SHARE,
true,
),
PLAYLIST_RECOMMENDATIONS: parseFeatureEnv(
import.meta.env.VITE_FEATURE_PLAYLIST_RECOMMENDATIONS,
true,
),
/**
* HLS Streaming
* Backend endpoints: /api/v1/tracks/:id/hls/info, /api/v1/tracks/:id/hls/status
*/
HLS_STREAMING: parseFeatureEnv(
import.meta.env.VITE_FEATURE_HLS_STREAMING,
true,
),
/**
* Role Management
* Backend endpoints: /api/v1/users/:userId/roles, /api/v1/roles/* (NOT IMPLEMENTED)
*/
ROLE_MANAGEMENT: parseFeatureEnv(
import.meta.env.VITE_FEATURE_ROLE_MANAGEMENT,
true,
),
/**
* Notifications API
* Backend endpoints: /api/v1/notifications/*
*/
NOTIFICATIONS: parseFeatureEnv(
import.meta.env.VITE_FEATURE_NOTIFICATIONS,
true,
),
} as const;
/**
* Type for feature flags
*/
export type FeatureFlag = keyof typeof FEATURES;
/**
* Check if a feature is enabled
*/
export function isFeatureEnabled(feature: FeatureFlag): boolean {
return Boolean(FEATURES[feature]);
}
/**
* Assert that a feature is enabled, throw error if not
*/
export function requireFeature(feature: FeatureFlag): void {
if (!isFeatureEnabled(feature)) {
throw new Error(
`Feature "${feature}" is not enabled. This feature is not available in the MVP.`,
);
}
}