cal.pub0.org/packages/features/flags/server/utils.ts

14 lines
387 B
TypeScript
Raw Normal View History

import type { PrismaClient } from "@prisma/client";
import type { AppFlags } from "../config";
export async function getFeatureFlagMap(prisma: PrismaClient) {
const flags = await prisma.feature.findMany({
orderBy: { slug: "asc" },
});
return flags.reduce<AppFlags>((acc, flag) => {
acc[flag.slug as keyof AppFlags] = flag.enabled;
return acc;
}, {} as AppFlags);
}