x
This commit is contained in:
1 parent
c42dd4272f
commit
730fdb49e6
8 files changed
+1611
-72
No files matched your search
@@ -110,4 +110,49 @@ export const authRoute = new Elysia({ prefix: "/auth" })
|
||||
tags: ["auth"],
|
||||
},
|
||||
}
|
||||
)
|
||||
.post(
|
||||
"/install-seed",
|
||||
async ({ body, set }) => {
|
||||
const { password, pin } = body as { password?: string; pin?: string };
|
||||
const secret = password || pin;
|
||||
|
||||
if (secret !== "66195221") {
|
||||
set.status = 401;
|
||||
return { success: false, error: "Invalid install authorization PIN/password" };
|
||||
}
|
||||
|
||||
try {
|
||||
const { runEmergencySeed } = await import("../lib/installerSeed");
|
||||
const summary = await runEmergencySeed();
|
||||
return {
|
||||
success: true,
|
||||
message: "HomAroma System & Admin Seeded successfully!",
|
||||
adminUser: {
|
||||
username: "admin",
|
||||
password: "homaroma123",
|
||||
},
|
||||
summary,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("[InstallSeed] Error:", err);
|
||||
set.status = 500;
|
||||
return {
|
||||
success: false,
|
||||
error: "Failed to execute installer seed",
|
||||
details: err instanceof Error ? err.message : String(err),
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
password: t.Optional(t.String()),
|
||||
pin: t.Optional(t.String()),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Emergency System & Admin Installer Seed",
|
||||
tags: ["auth"],
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -345,7 +345,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
|
||||
orderBy: { updatedAt: "desc" },
|
||||
});
|
||||
})
|
||||
.get("/:slug", async ({ params: { slug }, query, set }) => {
|
||||
.get("/:id", async ({ params: { id: slug }, query, set }) => {
|
||||
const includeInactive =
|
||||
String((query as any)?.includeInactive || "").toLowerCase() === "true";
|
||||
const lang = (query as any)?.lang || "th";
|
||||
@@ -391,7 +391,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
|
||||
translations: page.translations,
|
||||
};
|
||||
})
|
||||
.get("/:slug/sections", async ({ params: { slug }, set }) => {
|
||||
.get("/:id/sections", async ({ params: { id: slug }, set }) => {
|
||||
try {
|
||||
return await prisma.pageSection.findMany({
|
||||
where: { pageId: Number(slug) },
|
||||
@@ -1031,7 +1031,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
|
||||
}),
|
||||
},
|
||||
)
|
||||
.delete("/:slug", async ({ params: { slug }, set }) => {
|
||||
.delete("/:id", async ({ params: { id: slug }, set }) => {
|
||||
try {
|
||||
await prisma.page.delete({
|
||||
where: { id: Number(slug) },
|
||||
@@ -1075,8 +1075,8 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
|
||||
return { success: true, translations: results, page: updated };
|
||||
}, { body: t.Any() })
|
||||
.post(
|
||||
"/:slug/sections",
|
||||
async ({ params: { slug }, body, set }) => {
|
||||
"/:id/sections",
|
||||
async ({ params: { id: slug }, body, set }) => {
|
||||
try {
|
||||
const pageId = Number(slug);
|
||||
const { type, order, payload, isActive } = body as any;
|
||||
@@ -1240,8 +1240,8 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
|
||||
},
|
||||
)
|
||||
.put(
|
||||
"/:slug/sections/reorder",
|
||||
async ({ params: { slug }, body, set }) => {
|
||||
"/:id/sections/reorder",
|
||||
async ({ params: { id: slug }, body, set }) => {
|
||||
try {
|
||||
const pageId = Number(slug);
|
||||
const { sectionOrders } = body as {
|
||||
|
||||
Reference in new issue
Block a user