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>
34 lines
918 B
TypeScript
34 lines
918 B
TypeScript
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;
|
|
}
|