refactor: extract findUserOrder helper

This commit is contained in:
Kirill
2026-05-27 21:47:16 +05:00
parent 24b3b4063d
commit 45627206c0
5 changed files with 246 additions and 196 deletions
+12
View File
@@ -0,0 +1,12 @@
export async function findUserOrder(prisma, orderId, userId, include = {}) {
const order = await prisma.order.findFirst({
where: { id: orderId, userId },
include,
})
if (!order) {
throw Object.assign(new Error('Order not found'), { statusCode: 404 })
}
return order
}