webhook-architecture

Implements a 3-layer NestJS architecture for verifying, routing, and processing inbound webhooks.

Updated Jun 14, 2026
One-click install
npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill webhook-architecture-ironkid90-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webhook-architecture
Source: https://github.com/ironkid90-s/lucky5-v7/tree/main/.ptah/skills/webhook-architecture
Command: npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill webhook-architecture-ironkid90-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Inbound webhooks from external services like Stripe, Paddle, or GitHub are unreliable by nature: providers retry on non-200 responses, deliver duplicate events, and require signature verification against raw request bytes. Without a structured pattern, webhook endpoints become fragile, process duplicates, and lose failed events silently. ## Core Features & Use Cases - 3-Layer Separation: Controllers handle HTTP concerns only, a webhook service verifies signatures and routes events, and business services execute domain logic with one handler per event type. - Signature Verification: SDK-based verification for Stripe, Paddle, and GitHub plus manual HMAC with constant-time comparison and timestamp validation. - Resilience & Recovery: Idempotency via processed-event tracking, failed webhook storage with admin retry endpoints, always-200 responses, and optional BullMQ retry queues with exponential backoff. - Use Case: When integrating Paddle subscription events into a NestJS app, apply this pattern to verify the paddle-signature header, deduplicate event IDs in PostgreSQL via Prisma, and route subscription.created events to a dedicated handler while storing any failures for later retry. ## Quick Start Ask the AI to implement a NestJS webhook endpoint for your payment provider using the 3-layer webhook architecture with signature verification and idempotent processing.

Frequently Asked Questions about webhook-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle inbound webhooks in NestJS?

Use a 3-layer pattern: a thin controller extracts the raw body and signature headers, a webhook service verifies the signature and routes events by type, and business services execute domain logic. Enable rawBody in NestFactory and exclude webhook routes from the global API prefix.

How to verify Stripe or Paddle webhook signatures in Node.js?

Use the provider SDK: stripe.webhooks.constructEvent for Stripe or paddle.webhooks.unmarshal for Paddle, passing the raw request body and signature header. Without an SDK, compute an HMAC-SHA256 over the raw body and compare with crypto.timingSafeEqual.

Why should webhook endpoints always return 200?

Providers retry on non-2xx responses, causing duplicate processing and multiplied server load for one broken event. Return 200 for all outcomes, store failures internally, and reserve non-200 codes only for signature verification failures (401) or rate limiting (429).

How do I prevent duplicate webhook event processing?

Track processed event IDs in a database table and check before handling each event, or use upsert with the external event ID as a unique key. For high throughput above thousands per minute, use Redis SETNX with a TTL for faster deduplication lookups.

Why does webhook signature verification fail after JSON parsing?

Parsing and re-serializing JSON alters whitespace, key ordering, and unicode escapes, producing different bytes than the provider signed. Always compute the HMAC over the original raw request body buffer, which requires rawBody: true in NestJS.

When should I use a retry queue for failed webhooks?

Manual retry via admin endpoints suffices below roughly 100 failures per day. For medium volumes, use BullMQ with exponential backoff starting at 30 seconds across 5 attempts; high volumes above 10,000 per day warrant a dedicated worker process.