feat(backend): Webhooks mit HMAC-signierter Auslieferung (Modul 28)

WebhooksModule (WebhookSubscription: URL, Events, Secret, aktiv) mit
Event-Dispatcher, angehaengt an 10 Ereignisse in 8 bestehenden Services
(colony.created, inspection.created, queen.created, queen.replaced,
harvest.created, batch.created, batch.updated, product.stock_changed,
task.created, task.completed). Auslieferung ist best-effort und blockiert
die ausloesende Anfrage nicht bei Fehlern.
This commit is contained in:
Nick Szaunig committed 2026-08-23 06:56:56 +02:00
1 parent 8856d7d0f5
commit 59fdc816a0
26 files changed
+590 -8

No files matched your search

@@ -2,6 +2,7 @@ import { NotFoundException } from '@nestjs/common';
import { StorageService } from './storage.service';
import { PrismaService } from '../prisma/prisma.service';
import { AuditLogService } from '../audit/audit-log.service';
import { WebhooksService } from '../webhooks/webhooks.service';
describe('StorageService', () => {
let service: StorageService;
@@ -45,9 +46,11 @@ describe('StorageService', () => {
),
};
auditLog = { record: jest.fn() };
const webhooks = { dispatch: jest.fn().mockResolvedValue(undefined) };
service = new StorageService(
prisma as unknown as PrismaService,
auditLog as unknown as AuditLogService,
webhooks as unknown as WebhooksService,
);
});
@@ -1,6 +1,7 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { AuditLogService } from '../audit/audit-log.service';
import { WebhooksService } from '../webhooks/webhooks.service';
import { StockItem, StorageContainer } from '../../generated/prisma';
import { CreateStorageContainerDto } from './dto/create-storage-container.dto';
import { CreateStockItemDto } from './dto/create-stock-item.dto';
@@ -11,6 +12,7 @@ export class StorageService {
constructor(
private readonly prisma: PrismaService,
private readonly auditLog: AuditLogService,
private readonly webhooks: WebhooksService,
) {}
async findAllContainers(): Promise<StorageContainer[]> {
@@ -96,6 +98,8 @@ export class StorageService {
userId: actingUserId,
afterData: movement,
});
return this.findStockItemById(id);
const stockItem = await this.findStockItemById(id);
await this.webhooks.dispatch('product.stock_changed', stockItem);
return stockItem;
}
}