feat: implement real-time database synchronization with SSE and update backend modules
Test Suite / backend-pr-quick (24.15.0) (push) Has been cancelled
Test Suite / backend-full (24.15.0) (push) Has been cancelled
Test Suite / flutter-quality (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-12 16:57:05 +02:00
parent 2dda34d4d2
commit 98ee8a3ad6
11 changed files with 400 additions and 7 deletions
+24 -2
View File
@@ -1,5 +1,6 @@
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import { Prisma, PrismaClient } from '@prisma/client';
import { RealtimeEventsService } from '../realtime/realtime-events.service';
@Injectable()
export class PrismaService
@@ -7,9 +8,30 @@ export class PrismaService
implements OnModuleInit, OnModuleDestroy
{
private readonly logger = new Logger(PrismaService.name);
private readonly writeActions = new Set<string>([
'create',
'update',
'upsert',
'delete',
'createMany',
'updateMany',
'deleteMany',
]);
constructor() {
constructor(private readonly realtimeEvents: RealtimeEventsService) {
super();
const realtimeMiddleware: Prisma.Middleware = async (params, next) => {
const result = await next(params);
if (params.model && this.writeActions.has(params.action)) {
this.realtimeEvents.notifyDatabaseWrite();
}
return result;
};
this.$use(realtimeMiddleware);
}
async onModuleInit() {