Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

use zfd in other places

Sara Vieira140a93fb68ae
diff --git a/apps/designer/app/routes/dashboard/index.tsx b/apps/designer/app/routes/dashboard/index.tsx
index 6dfbbf0ef8..92d903e1bf 100644
--- a/apps/designer/app/routes/dashboard/index.tsx
+++ b/apps/designer/app/routes/dashboard/index.tsx
@@ -10,12 +10,16 @@ import * as db from "~/shared/db";
import config from "~/config";
import { ensureUserCookie } from "~/shared/session";
import { authenticator } from "~/services/auth.server";
+import { zfd } from "zod-form-data";
export { links };
+const schema = zfd.formData({
+ project: zfd.text(),
+});
+
export const action: ActionFunction = async ({ request }) => {
- const formData = await request.formData();
- const title = formData.get("project");
- if (typeof title !== "string") return { errors: "Title required" };
+ const { project: title } = schema.parse(await request.formData());
+
const { userId, headers } = await ensureUserCookie(request);
const authenticatedUser = await authenticator.isAuthenticated(request);
try {
diff --git a/apps/designer/app/routes/rest/publish.ts b/apps/designer/app/routes/rest/publish.ts
index 04f5bdeb34..29fa2dd5cf 100644
--- a/apps/designer/app/routes/rest/publish.ts
+++ b/apps/designer/app/routes/rest/publish.ts
@@ -1,10 +1,14 @@
import { type ActionFunction } from "@remix-run/node";
+import { zfd } from "zod-form-data";
import * as db from "~/shared/db";
+const schema = zfd.formData({
+ domain: zfd.text(),
+ projectId: zfd.text(),
+});
+
export const action: ActionFunction = async ({ request }) => {
- const formData = await request.formData();
- const domain = formData.get("domain") as string | null;
- const projectId = formData.get("projectId") as string | null;
+ const { domain, projectId } = schema.parse(await request.formData());
try {
const project = await db.misc.publish({ projectId, domain });
return { domain: project.domain };