Implementation
Built a multi-tenant webhook gateway where the hard part was guaranteed delivery — endpoints go down, networks drop, services restart. The solution was a BullMQ-backed delivery pipeline with exponential backoff retries, dead-letter handling for permanently failed jobs, and per-attempt logs so teams can debug exactly what happened. Every payload is HMAC-SHA256 signed so consumers can verify authenticity. The management API covers webhook creation, subscription management, manual replay, and team-level RBAC.
@Processor('webhook-delivery')
export class WebhookProcessor {
async process(job: Job<WebhookPayload>) {
const sig = this.hmac.sign(job.data.body, job.data.secret);
const res = await fetch(job.data.url, {
method: 'POST',
headers: { 'X-Webhook-Signature': sig },
body: JSON.stringify(job.data.body),
});
if (!res.ok) throw new Error(`Delivery failed: ${res.status}`);
await this.logs.record(job.id, res.status);
}
}
