This commit is contained in:
Kirill
2026-05-23 18:47:35 +05:00
parent bd9bdc0352
commit d0d7eab77e
16 changed files with 889 additions and 65 deletions
Binary file not shown.
+14
View File
@@ -204,4 +204,18 @@ export async function registerAuthRoutes(fastify) {
})
return { user: mapUserForClient(updated) }
})
fastify.delete('/api/me', { preHandler: [fastify.authenticate] }, async (request, reply) => {
const userId = request.user.sub
const ACTIVE_STATUSES = ['DRAFT', 'PENDING_PAYMENT', 'PAID', 'IN_PROGRESS', 'SHIPPED', 'READY_FOR_PICKUP']
const activeOrders = await prisma.order.findMany({
where: { userId, status: { in: ACTIVE_STATUSES } },
select: { id: true },
})
await prisma.user.delete({ where: { id: userId } })
return { ok: true, activeOrderIds: activeOrders.map((o) => o.id) }
})
}