/** * Database Adapter Singleton * * Provides a shared database adapter instance to prevent multiple connections. * All services should use this singleton instead of creating their own adapters. */ import { createDatabaseAdapter } from './factory.js'; import type { DatabaseAdapter } from './interface.js'; let dbAdapterInstance: DatabaseAdapter | null = null; /** * Get the shared database adapter instance */ export function getDatabaseAdapter(): DatabaseAdapter { if (!dbAdapterInstance) { dbAdapterInstance = createDatabaseAdapter(undefined, undefined, false); // Don't allow close (singleton) } return dbAdapterInstance; } /** * Reset the singleton (for testing only) */ export function resetDatabaseAdapter(): void { dbAdapterInstance = null; }