import { prisma } from '@/lib/db'
import { apiRoute } from '@/lib/api/handler'

export const dynamic = 'force-dynamic'

/** The Failure DNA library. */
export const GET = apiRoute({ permission: 'dna.read' }, async () =>
  prisma.failurePattern.findMany({
    include: { dna: true, region: { select: { code: true, name: true, nameAr: true } } },
    orderBy: { occurredAt: 'desc' },
  }),
)
