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

+25
View File
@@ -0,0 +1,25 @@
import { Elysia } from "elysia";
import prisma from "../lib/prisma";
export const customersRoute = new Elysia({ prefix: "/customers" })
.get("/", async () => {
return await prisma.customer.findMany({
orderBy: { createdAt: 'desc' },
include: {
_count: {
select: { orders: true }
}
}
});
})
.get("/:id", async ({ params: { id }, set }) => {
const customer = await prisma.customer.findUnique({
where: { id: Number(id) },
include: { orders: { orderBy: { createdAt: 'desc' } } }
});
if (!customer) {
set.status = 404;
return { error: "Customer not found" };
}
return customer;
});