refactoring to remove a lot of junk

This commit is contained in:
Boki 2025-06-22 16:57:08 -04:00
parent 5318158e59
commit d858222af7
33 changed files with 505 additions and 367 deletions

View file

@ -45,6 +45,3 @@ export type {
export { RedisConnectionManager } from './connection-manager';
export { CacheKeyGenerator } from './key-generator';
export { RedisCache } from './redis-cache';
// Default export for convenience
export default createCache;

View file

@ -1,5 +0,0 @@
// This factory is no longer needed when using Awilix DI
// The MongoDBClient is now registered directly in the DI container
// See: libs/core/di/src/awilix-container.ts
export { MongoDBClient } from './client';

View file

@ -1,29 +0,0 @@
import { PostgreSQLClient } from './client';
import type { PostgreSQLClientConfig, PostgreSQLConnectionOptions, ConnectionEvents } from './types';
/**
* Factory function to create a PostgreSQL client instance
*/
export function createPostgreSQLClient(
config: PostgreSQLClientConfig,
logger?: any,
options?: PostgreSQLConnectionOptions,
events?: ConnectionEvents
): PostgreSQLClient {
return new PostgreSQLClient(config, logger, options, events);
}
/**
* Create and connect a PostgreSQL client
*/
export async function createAndConnectPostgreSQLClient(
config: PostgreSQLClientConfig,
logger?: any,
options?: PostgreSQLConnectionOptions,
events?: ConnectionEvents
): Promise<PostgreSQLClient> {
const client = createPostgreSQLClient(config, logger, options, events);
await client.connect();
return client;
}

View file

@ -33,10 +33,5 @@ export type {
DynamicPoolConfig,
} from './types';
// Factory functions
export {
createPostgreSQLClient,
createAndConnectPostgreSQLClient,
} from './factory';
// Singleton pattern removed - use factory functions instead
// Note: Factory functions removed - instantiate directly with new PostgreSQLClient()
// or use the Awilix DI container (recommended)

View file

@ -1,26 +0,0 @@
import { QuestDBClient } from './client';
import type { QuestDBClientConfig, QuestDBConnectionOptions } from './types';
/**
* Factory function to create a QuestDB client instance
*/
export function createQuestDBClient(
config: QuestDBClientConfig,
logger?: any,
options?: QuestDBConnectionOptions
): QuestDBClient {
return new QuestDBClient(config, logger, options);
}
/**
* Create and connect a QuestDB client
*/
export async function createAndConnectQuestDBClient(
config: QuestDBClientConfig,
logger?: any,
options?: QuestDBConnectionOptions
): Promise<QuestDBClient> {
const client = createQuestDBClient(config, logger, options);
await client.connect();
return client;
}

View file

@ -28,5 +28,5 @@ export type {
InsertResult,
} from './types';
// Utils
export { createQuestDBClient, createAndConnectQuestDBClient } from './factory';
// Note: Factory functions removed - instantiate directly with new QuestDBClient()
// or use the Awilix DI container (recommended)

View file

@ -7,7 +7,6 @@
import { afterEach, describe, expect, it } from 'bun:test';
import {
createQuestDBClient,
QuestDBClient,
QuestDBHealthMonitor,
QuestDBInfluxWriter,
@ -40,9 +39,17 @@ describe('QuestDB Client Integration', () => {
});
describe('Client Initialization', () => {
it('should create client with factory function', () => {
const factoryClient = createQuestDBClient();
expect(factoryClient).toBeInstanceOf(QuestDBClient);
it('should create client with constructor', () => {
const newClient = new QuestDBClient({
host: 'localhost',
httpPort: 9000,
pgPort: 8812,
influxPort: 9009,
database: 'questdb',
user: 'admin',
password: 'quest',
});
expect(newClient).toBeInstanceOf(QuestDBClient);
});
it('should initialize all supporting classes', () => {