webhook-architecture

Implements a three-layer NestJS webhook handling pattern with validation, routing, and domain logic.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires nestjs, prisma, event-emitter, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a structured, three-layer webhook architecture pattern for NestJS applications, addressing the complexities of handling inbound webhooks from external services.

Core Features & Use Cases

  • Three-Layer Pattern: Implements a clear separation of concerns across HTTP validation, event verification and routing, and domain logic execution.
  • Event Handling: Offers a comprehensive approach to processing various event types (e.g., payments, subscriptions) from external services.
  • Security and Reliability: Ensures secure handling of signatures and idempotency checks to prevent duplicate processing and errors.
  • Use Case: For a payment processing system, this Skill ensures that payment events from providers are securely received, validated, and processed, maintaining data integrity and system reliability.

Quick Start

Run the 'processWebhook' function in the 'ExternalWebhookService' to handle incoming webhooks.

Frequently Asked Questions about webhook-architecture

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

FAQPage Schema
How do I structure webhook handling in NestJS to separate validation from business logic?

Structure webhook handling in NestJS using a three-layer pattern: HTTP validation, event verification and routing, and domain logic execution. This separation isolates signature checks and routing from core business processing, ensuring secure and maintainable inbound event workflows.

How do I prevent duplicate processing when receiving concurrent webhook events?

Prevent duplicate webhook processing by implementing idempotency checks within the event verification layer. This validates incoming HTTP callbacks against previously processed events, ensuring external services like payment providers do not trigger duplicate domain logic execution.

How do I verify webhook signatures for external service callbacks in NestJS?

Verify webhook signatures in NestJS by validating incoming HTTP requests within the first architectural layer. This security mechanism ensures that external service callbacks are authenticated before routing events to the domain logic execution layer.

Do I need Prisma and event emitter to handle webhooks in NestJS?

Yes, this webhook architecture requires Prisma and event emitter setup alongside NestJS. Prisma manages database operations for idempotency checks, while event emitter handles internal routing to the appropriate domain logic after HTTP validation.

What is the best way to route different webhook event types to specific handlers?

Route webhook event types by implementing a dedicated event verification and routing layer. After initial HTTP validation, this layer parses the event payload and uses event emitter to dispatch specific actions, like payments or subscriptions, to the correct domain logic.