Skip to content

feat(realtime): typed event contract, rate limiting, heartbeat + notifications listing - #1117

Merged
Akanimoh12 merged 1 commit into
Akanimoh12:test-implement-dripsfrom
codeX-james:feat/realtime-notifications-954-955-956-959
Jul 25, 2026
Merged

feat(realtime): typed event contract, rate limiting, heartbeat + notifications listing#1117
Akanimoh12 merged 1 commit into
Akanimoh12:test-implement-dripsfrom
codeX-james:feat/realtime-notifications-954-955-956-959

Conversation

@codeX-james

Copy link
Copy Markdown
Contributor

Summary

Resolves four assigned backend issues:

  • Realtime: Socket connection rate limiting #954 — Socket connection rate limiting. Added an in-memory sliding-window limiter: 20 new connections/min per IP (handshake middleware) and 30 client events/10s per socket, with a typed RATE_LIMITED error emitted back to the client.
  • Realtime: Socket heartbeat + reconnection docs #955 — Socket heartbeat + reconnection docs. Configured explicit pingInterval/pingTimeout on the Socket.IO server and documented heartbeat + client reconnection behavior in backend/docs/REALTIME.md.
  • Realtime: Realtime event type definitions (shared) #956 — Realtime event type definitions (shared). Expanded src/realtime/types.ts into the single typed contract for both sides: ServerToClientEvents, ClientToServerEvents, SocketData, including previously-untyped connected/error events (the old code used (socket as any).emit('error', ...)).
  • Notifications: GET /notifications (list, paginated) #959GET /notifications (list, paginated). Already fully implemented and tested on test-implement-drips; verified and left as-is.

Consolidation note

src/realtime/ had two parallel, divergent gateway implementations left over from prior merges (gateway.ts/auth.ts/types.ts, wired to tips.controller.ts via index.ts, vs. an unwired realtime.gateway.ts/realtime.auth.ts/realtime.types.ts). Kept the wired set as canonical, folded over the better ideas from the other (reusing the REST module's verifyAccessToken instead of duplicating JWT logic, graceful-shutdown registration), and deleted the dead duplicate. Also discovered initRealtime(httpServer) was implemented but never called — server.ts had it commented out — so realtime was effectively inert; it's now wired up.

Unrelated build-blocking fixes

While verifying npm run typecheck, found merge-artifact duplication (duplicate imports/enum/model fields) in app.ts, prisma/schema.prisma, and AppError.ts that broke tsc and prisma generate for the whole repo, not just these modules. Fixed those (mechanical dedup only, no behavior change) since nothing else could be verified without it.

Test plan

  • npm run typecheck — clean except one pre-existing, unrelated error in src/modules/x/x.test.ts
  • npm run lint — 0 errors (3 pre-existing warnings elsewhere, untouched files)
  • npm run test — all src/realtime/* and src/modules/notifications/* tests pass (27/27); other DB-backed integration suites (tips/auth/indexer/x) are unaffected by this change but require a local Postgres to run

Closes #954
Closes #955
Closes #956
Closes #959

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@codeX-james 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! 🚀

Learn more about application limits

@Akanimoh12

Copy link
Copy Markdown
Owner

Please resolve so I can merge please

…heartbeat config + docs

- Add a shared typed contract for Socket.IO events and payloads (SocketData,
  connected/error events) so client and server agree on shapes.
- Reuse the REST module's verifyAccessToken for the socket auth handshake
  instead of duplicating JWT verification.
- Throttle new connections per IP and client events per socket with a small
  in-memory sliding-window limiter; emit a typed RATE_LIMITED error.
- Configure explicit pingInterval/pingTimeout for heartbeat detection and
  document heartbeat + client reconnection behavior in docs/REALTIME.md.
- Wire initRealtime(httpServer) into server.ts — it was implemented but
  never actually started.
- Remove a duplicate, unwired realtime.* implementation left over from a
  prior merge and consolidate on the one already used by tips.controller.ts.
- Fix duplicate import/enum/model-field blocks in app.ts, schema.prisma, and
  AppError.ts (merge artifacts) that broke `tsc`/`prisma generate` repo-wide.

The notifications listing endpoint (GET /notifications, paginated) was
already fully implemented and tested on this branch; no changes needed.

Closes Akanimoh12#954
Closes Akanimoh12#955
Closes Akanimoh12#956
Closes Akanimoh12#959
@codeX-james
codeX-james force-pushed the feat/realtime-notifications-954-955-956-959 branch from 7fe57c7 to c905c46 Compare July 25, 2026 13:41
@Akanimoh12
Akanimoh12 merged commit 4662b76 into Akanimoh12:test-implement-drips Jul 25, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants