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

@@ -1,12 +1,16 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { WebhooksService } from '../webhooks/webhooks.service';
import { Inspection, Task } from '../../generated/prisma';
import { CreateInspectionDto } from './dto/create-inspection.dto';
import { CreateTaskFromInspectionDto } from './dto/create-task-from-inspection.dto';
@Injectable()
export class InspectionsService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly webhooks: WebhooksService,
) {}
async findAll(): Promise<Inspection[]> {
return this.prisma.inspection.findMany({ orderBy: { date: 'desc' } });
@@ -33,9 +37,11 @@ export class InspectionsService {
dto: CreateInspectionDto,
actingUserId: string,
): Promise<Inspection> {
return this.prisma.inspection.create({
const inspection = await this.prisma.inspection.create({
data: { ...dto, date: new Date(dto.date), userId: actingUserId },
});
await this.webhooks.dispatch('inspection.created', inspection);
return inspection;
}
async createTaskFromInspection(