Files
cmdb-insight/backend/src/services/database/singleton.ts
Bert Hausmans cdee0e8819 UI styling improvements: dashboard headers and navigation
- Restore blue PageHeader on Dashboard (/app-components)
- Update homepage (/) with subtle header design without blue bar
- Add uniform PageHeader styling to application edit page
- Fix Rapporten link on homepage to point to /reports overview
- Improve header descriptions spacing for better readability
2026-01-21 03:24:56 +01:00

29 lines
777 B
TypeScript

/**
* 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;
}