Skip to content

refactor: strict model types, Winston logging, and BullMQ queue migration (Closes #1847, #1848, #1851, #1855) - #1872

Merged
sublime247 merged 1 commit into
sublime247:mainfrom
YazarAyobami:refactor/1847-1848-1851-1855-strict-types-logging-queues
Aug 26, 2026
Merged

refactor: strict model types, Winston logging, and BullMQ queue migration (Closes #1847, #1848, #1851, #1855)#1872
sublime247 merged 1 commit into
sublime247:mainfrom
YazarAyobami:refactor/1847-1848-1851-1855-strict-types-logging-queues

Conversation

@YazarAyobami

Copy link
Copy Markdown
Contributor

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.ts on top of winston (already a project dependency) while preserving the full public API so call sites and tests are unaffected:

  • Structured JSON output in production via a printf-style format with a stable field order (timestamp, level, message, then context), paired with winston-daily-rotate-file for rotating file transport — matching the behavior the old logger provided.
  • PII scrubbing and masking preserved: the existing redaction/masking pipeline is wired into a custom log formatter, and the security/audit/child/RelaxedLogger helpers keep their previous semantics.
  • Telecom/console formatting for human-readable output in dev, and a silent transport under test (NODE_ENV === 'test') so suite output stays clean.
  • Typecheck-clean against the strict tsconfig, with new focused tests in src/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.
  • Generic row typing: pool.query<T>() / queryRead<T> / queryWrite<T> now carry concrete row types; row mappers are typed and shared where call sites were duplicating them.
  • Removed any / Record<string, any> on row shapes in favor of explicit interfaces (e.g. ReconciliationReport.summary, ledger account fields, metadata access).
  • Hardened loose access that strict typing surfaced: status is now an explicit union on TransactionRow, CreateTransactionData fields are optional where the insert defaults them, and call sites in paymentController, transactionController, worker, email, invoiceService, fraud, subscriptionJob, toml route and zkProofService were 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)

  • Replaced the unbounded NATS consumer callback buffer with a bounded FIFO semaphore (createBoundedSemaphore, exported and unit-tested in src/queue/__tests__/boundedSemaphore.test.ts) that applies backpressure via maxAckPending-style pacing instead of letting messages pile up in memory.
  • Hoisted repeated per-message log-field allocations in 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.ts now 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.ts registers a BullMQ Worker for the transaction queue; the webhook test was updated to capture the BullMQ processor and still passes.
  • Removed the now-dead RabbitMQ import from src/queue/index.ts. No remaining RabbitMQ consumers exist outside the main app (verified by grep across ingest-node/bridge-*/workers/*).

Verification

  • npx tsc --noEmit — passes
  • eslint on all changed files — passes
  • Targeted jest suites (logger, queue/worker webhook, bounded semaphore, sync queue retention, models) — pass; the few failing suites (e.g. logger.test.ts session-IP hashing, users.test.ts env-dependent cases) were confirmed pre-existing on main via stash-and-compare.
  • Prettier applied only to the files rewritten wholesale (logger.ts, model files); CI does not enforce formatting.

Notes

…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>
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

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

Learn more about application limits

@sublime247
sublime247 merged commit 2947fe5 into sublime247:main Aug 26, 2026
15 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