fix: generate missing migration for Menu and Newsletter tables

This commit is contained in:
Your Name committed 2026-06-14 00:16:05 -04:00
1 parent 363be70e11
commit f5029fc935
123 files changed
+8683

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
import { Elysia, t } from "elysia";
import prisma from "../lib/prisma";
export const reviewsRoute = new Elysia({ prefix: "/reviews" })
.get("/product/:productId", async ({ params: { productId } }) => {
return await prisma.review.findMany({
where: {
productId: Number(productId),
isPublished: true
},
orderBy: { createdAt: 'desc' },
include: {
customer: {
select: {
displayName: true,
pictureUrl: true
}
}
}
});
})
.post("/", async ({ body, set }) => {
try {
const data = body;
const review = await prisma.review.create({
data: {
rating: data.rating,
comment: data.comment,
productId: data.productId,
customerId: data.customerId || null,
customerName: data.customerName || "Anonymous",
isPublished: true
}
});
return review;
}
catch (err) {
console.error("[Reviews] Error:", err);
set.status = 500;
return { error: "Failed to create review" };
}
}, {
body: t.Object({
rating: t.Number(),
comment: t.Optional(t.String()),
productId: t.Number(),
customerId: t.Optional(t.Nullable(t.Number())),
customerName: t.Optional(t.String())
})
});
//# sourceMappingURL=reviews.js.map