Commit Graph

4 Commits

Author SHA1 Message Date
Julien Gautier d82c455973 fix(portal-bff): downgrade Prisma to 6.x for nestjs-prisma compatibility
CI / commits (pull_request) Failing after 5s
CI / scan (pull_request) Failing after 9s
CI / a11y (pull_request) Failing after 3s
CI / perf (pull_request) Failing after 4s
CI / check (pull_request) Failing after 3s
Prisma 7 introduced two breaking changes that conflict with
nestjs-prisma 0.27.0:

1. The `prisma-client` provider (new default in Prisma 7) outputs
   the typed client to a custom path declared in schema.prisma.
   nestjs-prisma's PrismaService extends @prisma/client's runtime,
   which boots through @prisma/client/default.js — that stub requires
   `.prisma/client/default` in a sibling node_modules tree. Only the
   legacy `prisma-client-js` generator populates that path.

2. PrismaClientOptions in Prisma 7 no longer exposes `datasourceUrl`
   nor `datasources`. Connection now requires a driver adapter
   (e.g. `@prisma/adapter-pg` for Postgres). nestjs-prisma 0.27.0
   does not pass an adapter, and `new PrismaClient(undefined)` is
   rejected with `PrismaClientInitializationError: PrismaClient needs
   to be constructed with a non-empty, valid PrismaClientOptions`.

Both quirks are Prisma 7's adapter-first architecture surfacing
through a still-Prisma-6-shaped wrapper. nestjs-prisma's peer-deps
say `^7.0.0` but its design assumes the older API. Working around
each issue separately leads further into bespoke wiring (custom
PrismaService, manual @prisma/adapter-pg setup) — bricolage on a
foundational layer.

Per CLAUDE.md ("default to stable, recognized, battle-tested
choices"), downgrade to Prisma 6.19 (still actively maintained):

- package.json: prisma + @prisma/client pinned to ^6 (resolved 6.19.3)
- apps/portal-bff/prisma/schema.prisma:
  - generator client: `prisma-client-js` (Prisma 6 default)
  - datasource db: explicit `url = env("DATABASE_URL")` (required by
    Prisma 6, was implicit in Prisma 7 via prisma.config.ts)
- apps/portal-bff/prisma.config.ts: removed (Prisma 7-only feature)
- apps/portal-bff/.gitignore: drop the now-irrelevant
  `/generated/prisma` entry (no custom output dir with prisma-client-js)

ADR-0006 ("Persistence — PostgreSQL with Prisma") is unchanged: it
specifies Prisma without pinning a version. The version choice is a
tactical detail.

Re-evaluate when nestjs-prisma releases an update aligned with
Prisma 7's adapter model.

Verified: pnpm exec prisma generate populates Prisma 6's
.prisma/client/default.{js,d.ts}; pnpm nx build portal-bff green.
Runtime serve to be re-verified locally before merge.
2026-05-04 10:22:04 +02:00
Julien Gautier 2b0e20bd85 chore: wire PostgreSQL + Prisma per ADR-0006
Add Prisma 7 + nestjs-prisma. The schema lives at
apps/portal-bff/prisma/schema.prisma with provider postgresql; the new
prisma-client generator (Prisma 7 default) outputs the typed client to
apps/portal-bff/generated/prisma/ which is gitignored.

apps/portal-bff/src/app/app.module.ts imports PrismaModule.forRoot
({ isGlobal: true }) so PrismaService is injectable across the BFF
without per-module imports.

apps/portal-bff/.env.example documents DATABASE_URL with a local-dev
default, plus a forward list of env vars introduced by upcoming phases
and ADRs (auth, sessions, MFA, observability, audit, downstream APIs)
- catalog reference, not implementation. The actual .env stays
gitignored at both repo root and app levels.

prisma.config.ts (Prisma 7's TypeScript config) is committed; it loads
DATABASE_URL via dotenv. Schema and migrations paths are pinned to
prisma/ relative to the bff app.

PostgreSQL provisioning, RLS policies for the dual-audience design,
the dedicated audit schema with role grants (audit_owner / audit_writer
/ audit_reader / audit_archiver per ADR-0013), and column-level
encryption for L3-scoped data are out of scope of this commit -
they belong with the future on-prem infrastructure ADR.
2026-04-30 17:28:54 +02:00
Julien Gautier 0774014599 fix(portal-bff): use bracket notation for process.env access
The strict-TS option noPropertyAccessFromIndexSignature: true (set in
tsconfig.base.json per ADR-0004) forbids dot-notation access on index
signatures. process.env is typed as { [key: string]: string | undefined }
so process.env.PORT must be written process.env['PORT']. The Nx
generator wrote the dot form by default; fix to comply with the
project's strict-TS bar.

Touched: portal-bff main.ts and the three portal-bff-e2e support files
(global-setup, global-teardown, test-setup).
2026-04-30 16:34:17 +02:00
Julien Gautier bea5e1954f chore: generate portal-shell and portal-bff apps per ADR-0004 / ADR-0005
Add the @nx/angular, @nx/nest, @nx/vite, @nx/eslint plugins, then
generate the two apps. Adjust the empty-template tsconfig.base.json
to be Angular-compatible (drop project references and customConditions
that the empty-template defaults to but Angular doesn't support; keep
the strict-TS extensions from ADR-0004).

apps/portal-shell (Angular 21):
- standalone APIs, routing, SCSS, esbuild
- vitest-angular as unitTestRunner, playwright for e2e
- strict mode
- tags scope:portal-shell, type:app
- app.config.ts wired with provideZonelessChangeDetection() per
  ADR-0004 (Angular 21 + Nx 22 generates without zone.js by default)

apps/portal-bff (NestJS 11):
- Express adapter (default per ADR-0005)
- Jest as unitTestRunner
- tags scope:portal-bff, type:app
- main.ts wired with a global ValidationPipe configured
  whitelist + forbidNonWhitelisted + transform per ADR-0005
- Phase-2 security additions (helmet, CORS, sessions, CSRF, rate
  limit, auth guards, error filter) deferred to their respective
  ADRs - placeholder comment in main.ts

Workspace dependencies: class-validator + class-transformer added
(required by NestJS ValidationPipe at runtime). Nx-generated
.gitignore additions (.angular, __screenshots__) merged into ours.
.vscode/extensions.json and launch.json added by Nx are kept (do not
override our existing settings.json).
2026-04-30 16:12:42 +02:00