refactor: strict model types, Winston logging, and BullMQ queue migration (Closes #1847, #1848, #1851, #1855) - #1872
Merged
sublime247 merged 1 commit intoAug 26, 2026
Conversation
…tion - sublime247#1847: Upgrade all database models to TypeScript strict types (typed row interfaces, generic query results, no more `any` index signatures). - sublime247#1851: Move logging implementation to a Winston structured logger while preserving the relaxed call signature, PII scrubbing, Loki and rotating file transports. - sublime247#1855: Replace the RabbitMQ transaction work queue with a BullMQ queue + worker (NATS path preserved). - sublime247#1848: Bound the sync worker's NATS consumer buffers with a FIFO semaphore and hoist per-job log fields. Closes sublime247#1847, sublime247#1848, sublime247#1851, sublime247#1855 Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@YazarAyobami 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! 🚀 |
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
This PR resolves four Wave contributor issues in one refactor bundle, aligning the codebase with the project's strict-TS and modern-infrastructure direction:
#1851 — Winston structured logger (
src/utils/logger.ts)Rewrote
src/utils/logger.tson top ofwinston(already a project dependency) while preserving the full public API so call sites and tests are unaffected:timestamp,level,message, then context), paired withwinston-daily-rotate-filefor rotating file transport — matching the behavior the old logger provided.security/audit/child/RelaxedLoggerhelpers keep their previous semantics.NODE_ENV === 'test') so suite output stays clean.tsconfig, with new focused tests insrc/utils/__tests__/loggerWinston.test.ts.#1847 — Strict types for all database models (
src/models/*)Upgraded every model file to strict TypeScript:
Transaction/TransactionRow,User/UserRow,LedgerEntry/Account/AccountBalanceRow,Referral,PaymentLink,AnchoredAsset,Snapshot,HistoricalPrice,RefreshTokenFamily,AdminStellarKey,ReconciliationReport,Vault/VaultProofArtifact,Merchant/MerchantWebhook,AmlAlert,Dispute,ComplianceDocument,Contact,Subscription,AuditLog.pool.query<T>()/queryRead<T>/queryWrite<T>now carry concrete row types; row mappers are typed and shared where call sites were duplicating them.any/Record<string, any>on row shapes in favor of explicit interfaces (e.g.ReconciliationReport.summary, ledger account fields, metadata access).statusis now an explicit union onTransactionRow,CreateTransactionDatafields are optional where the insert defaults them, and call sites inpaymentController,transactionController,worker,email,invoiceService,fraud,subscriptionJob,tomlroute andzkProofServicewere tightened to match — with zero behavior change (verified via typecheck + targeted tests).#1848 — Sync worker queue buffer memory optimization (
src/queue/nats.ts,src/queue/syncWorker.ts)createBoundedSemaphore, exported and unit-tested insrc/queue/__tests__/boundedSemaphore.test.ts) that applies backpressure viamaxAckPending-style pacing instead of letting messages pile up in memory.syncWorker.ts(stable field objects allocated once outside the hot loop) to cut per-message garbage, and confirmed the existing sync-queue retention logic remains intact.#1855 — BullMQ migration for transaction queue (
src/queue/transactionQueue.ts,src/queue/worker.ts)transactionQueue.tsnow uses BullMQ (already a dependency) backed by the project's Redis config, exposing the same job API (addTransactionJob, etc.) used across controllers and workers.worker.tsregisters a BullMQWorkerfor the transaction queue; the webhook test was updated to capture the BullMQ processor and still passes.src/queue/index.ts. No remaining RabbitMQ consumers exist outside the main app (verified by grep acrossingest-node/bridge-*/workers/*).Verification
npx tsc --noEmit— passeseslinton all changed files — passeslogger.test.tssession-IP hashing,users.test.tsenv-dependent cases) were confirmed pre-existing onmainvia stash-and-compare.logger.ts, model files); CI does not enforce formatting.Notes