feat: Resilient Webhook Ingestion System for Frontend External Triggers - #237
Closed
ACodehunter wants to merge 1 commit into
Closed
feat: Resilient Webhook Ingestion System for Frontend External Triggers#237ACodehunter wants to merge 1 commit into
ACodehunter wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing — opened from incorrect account. Will be re-opened from the correct account. |
Contributor
|
pr under review, if i find any wrong implementation i will notify you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #223
Summary
Builds a highly resilient, decoupled webhook ingestion pipeline that survives database outages by using a Redis-based message queue with a dedicated worker, exponential backoff retries, and a Dead Letter Queue.
Changes
New Files
backend/src/routes/webhooks.ts— Fast-ingest endpoint (POST /api/v1/webhooks/ingest). Verifies signature and immediately enqueues; returns200 OKwithin milliseconds.backend/src/services/queue.service.ts— Redis list-backed queue:enqueueWebhook,dequeueWebhook, andenqueueDLQ.backend/src/services/webhookWorker.ts— Standalone worker process that consumes the queue, processes business logic, and retries with exponential backoff before moving to DLQ.backend/src/utils/signature.ts— HMAC-SHA256 signature verification usingcrypto.timingSafeEqualto prevent timing attacks.backend/src/utils/redis.ts— Shared Redis client.Modified Files
backend/src/routes/index.ts— Registered webhook router at/webhooks.backend/.env.example— AddedWEBHOOK_SECRETandREDIS_URL.Implementation Details
Phase 1 — Fast-Ingest Endpoint
POST /api/v1/webhooks/ingestverifies theX-Webhook-Signatureheader and pushes the payload onto a Redis list immediately, returning200 { status: 'accepted' }without any business logic.Phase 2 — Worker Service
webhookWorker.tsruns as a separate process viaBLPOPon the Redis queue (blocking pop, zero-overhead). Processes each webhook with the actual business logic.Phase 3 — Cryptographic Signature Verification
HMAC-SHA256 signature is verified using
crypto.timingSafeEqualpreventing timing-based spoofing attacks. Unsigned requests are immediately rejected with401.Phase 4 — Dead Letter Queue + Exponential Backoff
2^attempt * 1000ms.webhooks:dlqRedis list for manual inspection and replay.