This repository contains code for using Hookdeck, used in various demos.
The stripe-fetch-before-process/
directory contains an Express.js application that demonstrates a common pattern for handling webhooks: fetching the latest state from the events API before processing.
See the README in the stripe-fetch-before-process/
directory for more details.
The general/
directory contains a Next.js application designed to receive and verify webhooks.
The src
directory holds the core source code for the Next.js application, including API routes and libraries for handling webhooks.
src/app/api/
: This is where the API endpoints are defined.shopify/route.ts
: Handles incoming Shopify webhooks, including signature verification to ensure they are legitimate.stripe/route.ts
: Manages Stripe webhooks with signature verification.stripe/invoices/route.ts
: A specific endpoint for Stripe invoice-related webhooks.stripe/subscriptions/route.ts
: A dedicated endpoint for Stripe subscription events.
src/lib/
: Contains utility functions.verify-hookdeck.ts
: A crucial utility for verifying the signature of webhooks forwarded by Hookdeck, ensuring they have not been tampered with.
The scripts
directory contains scripts for automating demo setup and event triggering.
delete_all.ts
: A cleanup script that removes all sources and destinations from your Hookdeck account and deletes local Terraform state files. This is useful for resetting the demo environment.shopify/trigger.ts
: Triggers a sample Shopifyorders/create
event to a specified URL, allowing you to test the Shopify webhook endpoint.stripe/batch.sh
: A shell script that uses the Stripe CLI to trigger a variety of Stripe events for both invoices and subscriptions. This is useful for simulating a high volume of events to test your webhook handling logic.
The deduplication/
directory contains a TypeScript application for demonstrating Hookdeck's deduplication capabilities. This is a sender-only demo that sends events to Hookdeck Sources to test deduplication functionality.
src/sendOne.ts
: Single event sender for testing basic event deliverysrc/sendDupes.ts
: Duplicate event sender with both payload-based and ID-based deduplication modessrc/sendFlood.ts
: Burst sender with configurable duplicate percentage for load testingsrc/utils/args.ts
: Command-line argument parsing utilities for flexible script configuration
See the README in the deduplication/
directory for detailed usage instructions and configuration options.
The transformation-reording/
directory contains a TypeScript scripts for demonstrating Hookdeck transformations and filter rule reordering.
This demo is designed for testing different scenarios with sample events, allowing you to understand how reordering Hookdeck Transformation and Filtering rules works in various subscription-related workflows.
- TypeScript sender scripts: Located in
src/
directory for sending different event types - Environment configuration: Uses
HOOKDECK_ENDPOINT_URL
for directing events to your Hookdeck endpoint
trigger:paused-subscription
: Sends paused subscription events using the sample datatrigger:trial-ending-soon
: Sends trial ending notification eventstrigger:generic-update
: Sends generic update events for general testingtrigger:all
: Runs all trigger scripts sequentially for comprehensive testing
Use the NPM scripts defined in the package.json
to trigger events and test the transformation and reordering capabilities. See the README in the transformation-reording/
directory for detailed setup instructions and configuration options.