Initial commit for homaroma

This commit is contained in:
Your Name committed 2026-06-03 08:39:12 +07:00
commit f2179cfe57
269 files changed
+22635

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
import { Elysia, t } from "elysia";
import prisma from "../lib/prisma";
export const settingsRoute = new Elysia({ prefix: "/settings" })
.get("/", async ({ set }) => {
try {
let settings = await prisma.storeSettings.findFirst();
if (!settings) {
settings = await prisma.storeSettings.create({
data: {}
});
}
return settings;
} catch (err) {
console.error("[Settings] Error:", err);
set.status = 500;
return { error: "Failed to fetch settings" };
}
})
.put("/", async ({ body, set }) => {
try {
const data = body as any;
let settings = await prisma.storeSettings.findFirst();
if (!settings) {
settings = await prisma.storeSettings.create({ data });
} else {
settings = await prisma.storeSettings.update({
where: { id: settings.id },
data
});
}
return settings;
} catch (err) {
console.error("[Settings] Error:", err);
set.status = 500;
return { error: "Failed to update settings" };
}
}, {
body: t.Object({
shippingFee: t.Number(),
bankName: t.String(),
bankAccountName: t.String(),
bankAccountNumber: t.String()
})
});