mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
* chore: remove nextjs-config * build fix * sentry update * nextjs update * feature flags doc * update readme * explicit nextjs env vars + remove feature-unrelated things and obsolete vars from config * full config removal * remove force-dynamic from pages * compile fix * restore claude-deleted tests * no sentry backward compat * better .env.example * AUTHENTIK_REFRESH_TOKEN_URL not so required * accommodate auth system to requiredLogin feature --------- Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
export const FEATURES = [
|
|
"requireLogin",
|
|
"privacy",
|
|
"browse",
|
|
"sendToZulip",
|
|
"rooms",
|
|
] as const;
|
|
|
|
export type FeatureName = (typeof FEATURES)[number];
|
|
|
|
export type Features = Readonly<Record<FeatureName, boolean>>;
|
|
|
|
export const DEFAULT_FEATURES: Features = {
|
|
requireLogin: true,
|
|
privacy: true,
|
|
browse: true,
|
|
sendToZulip: true,
|
|
rooms: true,
|
|
} as const;
|
|
|
|
function parseBooleanEnv(
|
|
value: string | undefined,
|
|
defaultValue: boolean = false,
|
|
): boolean {
|
|
if (!value) return defaultValue;
|
|
return value.toLowerCase() === "true";
|
|
}
|
|
|
|
// WARNING: keep process.env.* as-is, next.js won't see them if you generate dynamically
|
|
const features: Features = {
|
|
requireLogin: parseBooleanEnv(
|
|
process.env.NEXT_PUBLIC_FEATURE_REQUIRE_LOGIN,
|
|
DEFAULT_FEATURES.requireLogin,
|
|
),
|
|
privacy: parseBooleanEnv(
|
|
process.env.NEXT_PUBLIC_FEATURE_PRIVACY,
|
|
DEFAULT_FEATURES.privacy,
|
|
),
|
|
browse: parseBooleanEnv(
|
|
process.env.NEXT_PUBLIC_FEATURE_BROWSE,
|
|
DEFAULT_FEATURES.browse,
|
|
),
|
|
sendToZulip: parseBooleanEnv(
|
|
process.env.NEXT_PUBLIC_FEATURE_SEND_TO_ZULIP,
|
|
DEFAULT_FEATURES.sendToZulip,
|
|
),
|
|
rooms: parseBooleanEnv(
|
|
process.env.NEXT_PUBLIC_FEATURE_ROOMS,
|
|
DEFAULT_FEATURES.rooms,
|
|
),
|
|
};
|
|
|
|
export const featureEnabled = (featureName: FeatureName): boolean => {
|
|
return features[featureName];
|
|
};
|