gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery

This commit is contained in:
2026-03-21 11:59:53 +01:00
parent 09e87c951b
commit c3edb8ad2e
1491 changed files with 265550 additions and 1292 deletions
+60
View File
@@ -0,0 +1,60 @@
import { AsyncLocalStorage } from 'async_hooks';
/**
* Audit-Kontext für die Übertragung von Before/After-Werten
* zwischen Prisma-Middleware und Audit-Middleware
*/
export interface AuditContext {
before?: Record<string, unknown>;
after?: Record<string, unknown>;
}
// AsyncLocalStorage für den Audit-Kontext
const auditStorage = new AsyncLocalStorage<AuditContext>();
/**
* Startet einen neuen Audit-Kontext für einen Request
*/
export function runWithAuditContext<T>(fn: () => T): T {
return auditStorage.run({}, fn);
}
/**
* Setzt die "Before"-Werte im aktuellen Kontext
*/
export function setBeforeValues(values: Record<string, unknown>): void {
const context = auditStorage.getStore();
if (context) {
context.before = values;
}
}
/**
* Setzt die "After"-Werte im aktuellen Kontext
*/
export function setAfterValues(values: Record<string, unknown>): void {
const context = auditStorage.getStore();
if (context) {
context.after = values;
}
}
/**
* Holt den aktuellen Audit-Kontext
*/
export function getAuditContext(): AuditContext | undefined {
return auditStorage.getStore();
}
/**
* Express Middleware zum Initialisieren des Audit-Kontexts
*/
export function auditContextMiddleware(
req: unknown,
res: unknown,
next: () => void
): void {
runWithAuditContext(() => {
next();
});
}