mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-11 18:58:45 -06:00
24 lines
742 B
TypeScript
24 lines
742 B
TypeScript
import { ActionClass } from "@prisma/client";
|
|
import { cache as reactCache } from "react";
|
|
import { z } from "zod";
|
|
import { prisma } from "@formbricks/database";
|
|
import { DatabaseError } from "@formbricks/types/errors";
|
|
import { validateInputs } from "@/lib/utils/validate";
|
|
|
|
export const getActionClasses = reactCache(async (environmentId: string): Promise<ActionClass[]> => {
|
|
validateInputs([environmentId, z.string().cuid2()]);
|
|
|
|
try {
|
|
return await prisma.actionClass.findMany({
|
|
where: {
|
|
environmentId: environmentId,
|
|
},
|
|
orderBy: {
|
|
createdAt: "asc",
|
|
},
|
|
});
|
|
} catch (error) {
|
|
throw new DatabaseError(`Database error when fetching actions for environment ${environmentId}`);
|
|
}
|
|
});
|