refactor(worker): Sprint 2 β dead code removal and queue consolidationβ
CognxSafeTrack+1: Claude Sonnet 4.6
37fb9ce
H1: Delete credit-guard.ts (worker) and credit-cache.ts (api) β both fully
superseded by wallet.ts/requireCredits.ts since the wallet migration.
H6: Introduce lib/queues.ts with shared whatsappQueue and notificationQueue
instances. Replace all 10 inline `new Queue(...)` calls across wallet.ts,
usage-tracker.ts, whatsapp-logic.ts, scheduler.ts, and 4 handlers.
Removes 10 redundant Redis connections; drops `q.close()` calls on
ephemeral instances that were killing the shared connection.
Shutdown handler now explicitly closes both shared queues.
Scratch: Move apps/api/scratch/ one-shot DB scripts to scripts/db-ops/
so they don't ship in the production API bundle.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>