feat: Grundgeruest fertigstellen (Backend/Frontend/K8s)
Backend: Prisma-Client auf prisma-client-js + Driver-Adapter (@prisma/adapter-pg) umgestellt (Prisma 7 verlangt Adapter, ESM-Client brach an Jest), erste Migration erzeugt und angewendet, /api/v1 Versioning, Swagger unter /api/v1/docs, Helmet, globale ValidationPipe, PrismaModule, HealthModule (/health, /health/ready mit DB-Check), tsconfig.build.json Root-Dir-Fix (dist/main.js statt dist/src/main.js). Frontend: Tailwind v4 + shadcn/ui initialisiert, TanStack Query Provider, PWA Manifest (app/manifest.ts), Vitest + Testing Library Setup, next.config output standalone. deploy/k8s: Dockerfiles (Backend/Frontend, Multi-Stage) + Deployment/Service/ Ingress/ConfigMap/Secret-Vorlagen fuer beide Projekte. Lokale Dev-/Test-Postgres-Instanz unter ApiCore-Backend/.devdb angelegt (eigene Rolle, kein bestehendes Passwort noetig), .env/.env.test lokal befuellt. Lint, Typecheck, Tests und Build sind fuer Backend und Frontend gruen; Server wurde lokal gestartet und /health, /health/ready, /api/v1/docs manuell verifiziert.
This commit is contained in:
1 parent
c4a2d0648e
commit
eae3fea957
57 files changed
+15114
-35
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { ServiceUnavailableException } from '@nestjs/common';
|
||||
import { HealthController } from './health.controller';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
describe('HealthController', () => {
|
||||
let controller: HealthController;
|
||||
let prisma: { $queryRaw: jest.Mock };
|
||||
|
||||
beforeEach(() => {
|
||||
prisma = { $queryRaw: jest.fn() };
|
||||
controller = new HealthController(prisma as unknown as PrismaService);
|
||||
});
|
||||
|
||||
it('liveness returns ok without touching the database', () => {
|
||||
expect(controller.liveness()).toEqual({ status: 'ok' });
|
||||
expect(prisma.$queryRaw).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('readiness returns ok when the database responds', async () => {
|
||||
prisma.$queryRaw.mockResolvedValueOnce([{ '?column?': 1 }]);
|
||||
await expect(controller.readiness()).resolves.toEqual({ status: 'ok' });
|
||||
});
|
||||
|
||||
it('readiness throws ServiceUnavailableException when the database is unreachable', async () => {
|
||||
prisma.$queryRaw.mockRejectedValueOnce(new Error('connection refused'));
|
||||
await expect(controller.readiness()).rejects.toBeInstanceOf(
|
||||
ServiceUnavailableException,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user