feat(backend): SQL optimization, error recovery, security audit, rate limiting#1014
Closed
davedumto wants to merge 1 commit into
Closed
feat(backend): SQL optimization, error recovery, security audit, rate limiting#1014davedumto wants to merge 1 commit into
davedumto wants to merge 1 commit into
Conversation
… audit, rate limiting for websocket relay and payment processor - emdevelopa#919: websocket-relay-queries.js — paginated getRecentEvents, batch batchInsertEvents, SKIP LOCKED dequeueNextEvent; all queries guarded with SET LOCAL statement_timeout = 5s; index recommendations documented - emdevelopa#920: websocket-relay-recovery.js — exponential backoff reconnectWithBackoff, three-state CircuitBreaker (CLOSED/OPEN/HALF_OPEN), DeadLetterQueue, getRelayHealth snapshot - emdevelopa#921: websocket-relay-security.js — validateOrigin whitelist, enforceMessageSizeLimit (64 KiB default), verifyRelayToken (HS256 only), sanitizeRelayMessage (unknown-field stripping), auditRelayEvent structured logging - emdevelopa#922: payment-rate-limiter.js — in-memory sliding-window Express middleware; X-RateLimit-* headers; 429 with retryAfter; independent per-key tracking; no Redis dependency All 80 new tests pass (vitest).
|
@davedumto is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@davedumto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Closing in favour of a replacement PR with correct issue linking. |
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.
Summary
websocket-relay-queries.jsaddsgetRecentEvents(paginated, descending),batchInsertEvents(single multi-rowINSERT), anddequeueNextEvent(SELECT … FOR UPDATE SKIP LOCKED). All three wrap queries inSET LOCAL statement_timeout = '5s'. Index recommendations are documented in the file header.websocket-relay-recovery.jsprovidesreconnectWithBackoff(exponential backoff + jitter),CircuitBreaker(CLOSED/OPEN/HALF_OPEN states, configurable threshold + reset timeout),DeadLetterQueue(failed messages with error metadata + retry count), andgetRelayHealth(single snapshot for monitoring).websocket-relay-security.jsaddsvalidateOrigin(exact-match whitelist, no wildcards),enforceMessageSizeLimit(64 KiB default, works on strings/Buffers/objects),verifyRelayToken(HS256-onlyjsonwebtokenwrapper),sanitizeRelayMessage(strips unknown fields, requirestype), andauditRelayEvent(structured JSON audit log).payment-rate-limiter.jsprovidescreatePaymentRateLimiter— an in-memory sliding-window Express middleware with per-key tracking,X-RateLimit-*headers, 429 +retryAfterbody, and automatic eviction of stale entries. No Redis dependency.Test plan
npx vitest run src/lib/websocket-relay-queries.test.js src/lib/websocket-relay-recovery.test.js src/lib/websocket-relay-security.test.js src/middleware/payment-rate-limiter.test.js)npm test)closes #919
closes #920
closes #921
closes #922