This commit is contained in:
Your Name committed 2026-06-07 07:33:41 +07:00
1 parent 724c4c66c9
commit 4d5db0c9dd
11 files changed
+644 -38

No files matched your search

+31
View File
@@ -183,4 +183,35 @@ export const productsRoute = new Elysia({ prefix: "/products" })
tags: ["products"],
},
}
)
.patch(
"/:id",
async ({ params, body, status }) => {
const id = parseInt(params.id);
if (isNaN(id)) return status(400, { message: "Invalid product ID" });
try {
const prod = await prisma.product.update({
where: { id },
data: body,
});
return { success: true, product: prod };
} catch (err: any) {
console.error("Patch product error:", err);
return status(500, { success: false, message: "Failed to patch product" });
}
},
{
body: t.Object({
name: t.Optional(t.String()),
categoryId: t.Optional(t.Number()),
scentId: t.Optional(t.Nullable(t.Number())),
description: t.Optional(t.String()),
details: t.Optional(t.String()),
}),
detail: {
summary: "Partial Update Product",
tags: ["products"],
},
}
);