Files
myeasycms-v2/apps/web/config/feature-flags.config.ts
giancarlo 7579ee9a2c Refactor authentication flow and improve code organization
The update implemented a redirect functionality in the multi-factor authentication flow for a better user experience. It also involved a refactoring of some parts of the code, substituting direct routing paths with path configs for easier future modifications. Import statements were adjusted for better code organization and readability.
2024-03-27 15:07:15 +08:00

50 lines
1.3 KiB
TypeScript

import { z } from 'zod';
const FeatureFlagsSchema = z.object({
enableThemeSwitcher: z.boolean(),
enableAccountDeletion: z.boolean(),
enableOrganizationDeletion: z.boolean(),
enableOrganizationAccounts: z.boolean(),
enableOrganizationCreation: z.boolean(),
enablePersonalAccountBilling: z.boolean(),
enableOrganizationBilling: z.boolean(),
});
const featuresFlagConfig = FeatureFlagsSchema.parse({
enableThemeSwitcher: true,
enableAccountDeletion: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_ACCOUNT_DELETION,
false,
),
enableOrganizationDeletion: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_ORGANIZATION_DELETION,
false,
),
enableOrganizationAccounts: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_ORGANIZATION_ACCOUNTS,
true,
),
enableOrganizationCreation: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_ORGANIZATION_CREATION,
true,
),
enablePersonalAccountBilling: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING,
false,
),
enableOrganizationBilling: getBoolean(
process.env.NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING,
false,
),
} satisfies z.infer<typeof FeatureFlagsSchema>);
export default featuresFlagConfig;
function getBoolean(value: unknown, defaultValue: boolean) {
if (typeof value === 'string') {
return value === 'true';
}
return defaultValue;
}