Skip to content

infra: implement shared connection pool management (#139)#298

Open
sheyman546 wants to merge 1 commit into
XStreamRollz:mainfrom
sheyman546:infra/shared-connection-pool-139
Open

infra: implement shared connection pool management (#139)#298
sheyman546 wants to merge 1 commit into
XStreamRollz:mainfrom
sheyman546:infra/shared-connection-pool-139

Conversation

@sheyman546

@sheyman546 sheyman546 commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Fixes #139. Replaces six independent new Pool() instances with a single shared pg.Pool provided via NestJS DI.

Changes

  • api/src/database/database.module.ts — new @Global() module exporting a singleton Pool under the PG_POOL injection token
  • api/src/app.module.ts — imports DatabaseModule (one import propagates the token globally)
  • Six consumers updated to @Inject(PG_POOL) instead of new Pool():
    • StreamsDbRepository
    • TagsDbRepository
    • UsersRepository
    • AuditService
    • PasswordResetService
    • DatabaseHealthIndicator (removed now-redundant OnModuleDestroy)
  • api/src/database/database.module.spec.ts — verifies singleton Pool provision

Tested

- Add api/src/database/database.module.ts as a @global NestJS module
  that provides a single pg.Pool instance under the PG_POOL token
- Remove individual new Pool() calls from StreamsDbRepository,
  TagsDbRepository, UsersRepository, AuditService,
  PasswordResetService, and DatabaseHealthIndicator
- Inject PG_POOL via @Inject(PG_POOL) in all six consumers
- Import DatabaseModule in AppModule; @global() propagates the token
  to all feature modules automatically
- Add database.module.spec.ts verifying singleton Pool provision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

infra: Implement shared connection pool management (api/src/database/ + 3 services)

1 participant