feat(api): outbound webhooks — server_down + player_banned events
Roadmap 'Webhook events': per-license outbound webhooks with HMAC-SHA256 signatures (X-Corrosion-Signature), 5s timeout, fire-and-forget (a webhook failure never breaks the triggering action), last_delivery_at/last_status tracked. - migration 024_webhooks; Webhook entity (events as simple-array); WebhooksModule (@Global, exports WebhooksService) wired into app.module; CRUD controller (license-scoped, webhooks.view/manage). - Hooked events: players.performAction ban -> 'player_banned'; host-agent-consumer going-offline + staleness sweep -> 'server_down'. - 'wipe_completed' event lands next (needs wipe status from the agent reply). Backend tsc green. Migration applies on a fresh DB (Saturday). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
33
backend-nest/src/modules/webhooks/dto/create-webhook.dto.ts
Normal file
33
backend-nest/src/modules/webhooks/dto/create-webhook.dto.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { IsString, IsNotEmpty, IsUrl, IsArray, ArrayNotEmpty, IsOptional, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateWebhookDto {
|
||||
@ApiProperty({ description: 'Human-readable label for this webhook', maxLength: 100 })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(100)
|
||||
name: string;
|
||||
|
||||
@ApiProperty({ description: 'HTTPS URL to POST events to' })
|
||||
@IsUrl({ protocols: ['https', 'http'], require_tld: false })
|
||||
url: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Event keys to subscribe to',
|
||||
example: ['player_banned', 'server_down'],
|
||||
type: [String],
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayNotEmpty()
|
||||
@IsString({ each: true })
|
||||
events: string[];
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'HMAC-SHA256 signing secret. Auto-generated if omitted.',
|
||||
maxLength: 128,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(128)
|
||||
secret?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user