Work / Scrvio / Wiki / Decisions
2026-10-23-infra-may-touch-prisma
Decisioncanonicalverified 2026-10-23
DECISION.2026-10-23.INFRA-MAY-TOUCH-PRISMADecision
Two infrastructure files may use PrismaService directly; nothing else outside a repository may. They are src/api/00-metrics/health.controller.ts (the SELECT 1 connection ping) and src/shared/utils/transaction.utils.ts (opens a $transaction that several repositories then share). The only-repositories-touch-prisma rule in apps/server/.dependency-cruiser.cjs names exactly these two files.
Why
The server layering says only repositories call this.prisma. That keeps queries, soft-delete filtering and type conversion in one layer. Neither file holds business logic or queries a model.
- The health ping checks the connection itself, not any data.
- A transaction spans repositories by design; the helper only opens it and hands each repository the transaction client.
Options weighed:
- Move both into repositories — rejected: a repository for a raw ping, or for "a transaction", has no model to own.
- Exempt
src/shared/orsrc/api/00-metrics/as a whole — rejected: too wide; a future helper or metrics query could reach Prisma freely. - Name the two files — chosen. Any new exception needs its own decision.
The same exception was made in dwarseva for the same reasons.
Impact
zeno checkfails if any other non-repository file importsPrismaService.- Adding a third exception means editing this page and the rule together.
Status
Active
Sources
- apps/server/.dependency-cruiser.cjs — rule
only-repositories-touch-prisma - apps/server/src/api/00-metrics/health.controller.ts
- apps/server/src/shared/utils/transaction.utils.ts