feat: WebSocket notifications template#7
Draft
gmoz22 wants to merge 10 commits into
Draft
Conversation
Serverless backend + React MFE for pushing EventBridge events to browser clients in sub-second latency, with missed-event replay and live resubscription — without polling or per-user queues. Backend (template-websocket-service): - EventBridge → broadcast Lambda (aws-lambda-stream pipeline) → API Gateway WebSocket push; events persisted to EventsTable with TTL - WebSocket lifecycle: connect, disconnect, replay, subscribe handlers - SubscriptionsTable supports per-type and catch-all (*) subscriptions - Missed-event replay on reconnect via client-triggered replay route - Live resubscription without reconnecting via subscribe route - Cross-region forwarding via EventBridge rule (opt-in, commented out) - Transformation logic (toMessage, toConnections, toUpdateRequest) extracted to src/models/websocket.js following template-bff-service pattern - Full unit test coverage (c8 + Mocha + Chai) across broadcast, connections, and models Frontend (template-websocket-mfe): - useWebSocket hook: connects, auto-reconnects with exponential backoff, handles live resubscription and opt-in missed-event replay via sessionStorage - App, ConnectionStatus, EventLog, TagInput components - Single-SPA lifecycle integration, Vite build, dark console UI Co-authored-by: Copilot <copilot@github.com>
Serverless backend + React MFE for pushing EventBridge events to browser clients in sub-second latency, with missed-event replay and live resubscription — without polling or per-user queues. Backend (template-websocket-service): - EventBridge → broadcast Lambda (aws-lambda-stream pipeline) → API Gateway WebSocket push; events persisted to EventsTable with TTL - WebSocket lifecycle: connect, disconnect, replay, subscribe handlers - SubscriptionsTable supports per-type and catch-all (*) subscriptions - Missed-event replay on reconnect via client-triggered replay route - Live resubscription without reconnecting via subscribe route - Cross-region forwarding via EventBridge rule (opt-in, commented out) - Transformation logic (toMessage, toConnections, toUpdateRequest) extracted to src/models/websocket.js following template-bff-service pattern - Full unit test coverage (c8 + Mocha + Chai) across broadcast, connections, and models Frontend (template-websocket-mfe): - useWebSocket hook: connects, auto-reconnects with exponential backoff, handles live resubscription and opt-in missed-event replay via sessionStorage - App, ConnectionStatus, EventLog, TagInput components - Single-SPA lifecycle integration, Vite build, dark console UI
Author
|
Dependency: MR #441 on |
- Add template-websocket-demo with deploy, demo, and cleanup scripts, serverless config, and an EventBridge emitter - Add build:standalone mode to template-websocket-mfe (Vite standalone output to dist/standalone) - Fix config.yml: rename hubStack → busStack and update CloudFormation cross-references accordingly - Update READMEs to reference template-websocket-demo and document aws-lambda-stream v1.2.0 requirement
…ates into websocket
…ress - Check CloudFormation if stacks are deployed, else trigger a full deploy - Add AWS CLI v1 detection and Node.js version check to preflight, remove redundant serverless --version check - docs: clarify AWS_PROFILE step in prerequisites
…ress - Check CloudFormation if stacks are deployed, else trigger a full deploy - Add AWS CLI v1 detection and Node.js version check to preflight, remove redundant serverless --version check - docs: clarify AWS_PROFILE step in prerequisites
…ates into websocket
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.
Serverless backend + React MFE for pushing EventBridge events to browser clients in sub-second latency, with missed-event replay and live resubscription, without polling or per-user queues. Includes an end-to-end demo that deploys all infrastructure and hosts the MFE from a single terminal.
Backend —
template-websocket-serviceaws-lambda-streampipeline) → API Gateway WebSocket push; events persisted toEventsTablewith TTL*) subscriptionstoMessage,toConnections, andtoUpdateRequesttransformation logic insrc/models/websocket.jsFrontend —
template-websocket-mfeuseWebSockethook: connects, auto-reconnects with exponential backoff, handles live resubscription and opt-in missed-event replay via sessionStorageApp,ConnectionStatus,EventLog,TagInputcomponentsDemo —
template-websocket-demoscripts/deploy.sh— deploys the EventBridge bus, WebSocket service, and MFE to S3 + CloudFront in sequencescripts/demo.sh— interactive CLI runner for emitting test events and observing live pushes end-to-endscripts/cleanup.sh— tears down all deployed stacks and S3 assetssrc/emit.js— standalone EventBridge emitter for triggering test notificationsserverless.yml— minimal Serverless Framework config for the demo bus stackSee README.md for more info.
Previewing the WebSocket feature outside of the official
aws-lambda-streamlibraryIn the
/additional/template-websocket-notifications/template-websocket-service/folder, modifypackage.jsonto point to the folder of the localaws-lambda-streamwebsocketbranch:"aws-lambda-stream": "file:../aws-lambda-stream-websocket/",or
"aws-lambda-stream": "file:/Users/gmoz22/WEBDEV/aws-lambda-stream-websocket/",And run
npm installto make sure it works.DEMO (5m)