x
This commit is contained in:
1 parent
e405af357c
commit
e1cf9e62e7
51 files changed
+2598
-168
No files matched your search
@@ -115,4 +115,55 @@ export const settingsRoute = new Elysia({ prefix: "/settings" })
|
||||
set.status = 500;
|
||||
return { error: "Failed to update settings translation" };
|
||||
}
|
||||
})
|
||||
.post("/seed-pages", async ({ set }) => {
|
||||
try {
|
||||
const REQUIRED_PAGES = [
|
||||
{ slug: "home", title: "Home Page" },
|
||||
{ slug: "shop-layout", title: "Shop Page Layout" },
|
||||
{ slug: "scent-guide-layout", title: "Scent Guide Layout" },
|
||||
{ slug: "category-layout", title: "Category Page Layout" },
|
||||
{ slug: "product-detail-layout", title: "Product Detail Layout" },
|
||||
{ slug: "faq-layout", title: "FAQ Page Layout" },
|
||||
{ slug: "wishlist-layout", title: "Wishlist Page Layout" },
|
||||
{ slug: "search-layout", title: "Search Page Layout" },
|
||||
{ slug: "coupons-layout", title: "Coupons Page Layout" },
|
||||
{ slug: "contact-layout", title: "Contact Page Layout" },
|
||||
{ slug: "order-success-layout", title: "Order Success Page Layout" },
|
||||
{ slug: "track-order-layout", title: "Track Order Page Layout" },
|
||||
{ slug: "checkout-layout", title: "Checkout Page Layout" },
|
||||
{ slug: "profile-layout", title: "Profile Page Layout" },
|
||||
];
|
||||
|
||||
const results: { slug: string; status: "created" | "exists" }[] = [];
|
||||
|
||||
for (const page of REQUIRED_PAGES) {
|
||||
const existing = await prisma.page.findUnique({ where: { slug: page.slug } });
|
||||
if (!existing) {
|
||||
await prisma.page.create({
|
||||
data: {
|
||||
slug: page.slug,
|
||||
title: page.title,
|
||||
isPublished: true,
|
||||
}
|
||||
});
|
||||
results.push({ slug: page.slug, status: "created" });
|
||||
} else {
|
||||
results.push({ slug: page.slug, status: "exists" });
|
||||
}
|
||||
}
|
||||
|
||||
const created = results.filter(r => r.status === "created").length;
|
||||
const existed = results.filter(r => r.status === "exists").length;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Seed complete: ${created} pages created, ${existed} pages already existed.`,
|
||||
results
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("[Settings] Seed Pages Error:", err);
|
||||
set.status = 500;
|
||||
return { error: "Failed to seed pages" };
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user