first refactor
This commit is contained in:
parent
1f5dac28c7
commit
588f666943
84 changed files with 996 additions and 1062 deletions
|
|
@ -5,12 +5,11 @@ import type {
|
|||
HandlerConfigWithSchedule,
|
||||
HandlerMetadata,
|
||||
IHandler,
|
||||
IServiceContainer,
|
||||
JobHandler,
|
||||
ServiceTypes,
|
||||
} from '@stock-bot/types';
|
||||
import type { IServiceContainer, ServiceTypes } from '@stock-bot/services';
|
||||
import { fetch } from '@stock-bot/utils';
|
||||
import type { Collection } from 'mongodb';
|
||||
import type { Collection, Document } from 'mongodb';
|
||||
// Handler registry is now injected, not imported
|
||||
import { createJobHandler } from '../utils/create-job-handler';
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ export abstract class BaseHandler<TServices extends ServiceTypes = ServiceTypes>
|
|||
constructor.__handlerName || handlerName || this.constructor.name.toLowerCase();
|
||||
|
||||
// Flatten all services onto the handler instance
|
||||
this.logger = getLogger(this.constructor.name) as TServices['logger'];
|
||||
this.logger = (services.logger ?? getLogger(this.constructor.name)) as TServices['logger'];
|
||||
this.cache = services.cache as TServices['cache'];
|
||||
this.globalCache = services.globalCache as TServices['globalCache'];
|
||||
this.queueManager = services.queueManager as TServices['queueManager'];
|
||||
|
|
@ -160,11 +159,11 @@ export abstract class BaseHandler<TServices extends ServiceTypes = ServiceTypes>
|
|||
/**
|
||||
* Get a MongoDB collection with type safety
|
||||
*/
|
||||
protected collection<T extends {} = any>(name: string): Collection<T> {
|
||||
protected collection<T extends Document = Document>(name: string): Collection<T> {
|
||||
if (!this.mongodb) {
|
||||
throw new Error('MongoDB service is not available');
|
||||
}
|
||||
return this.mongodb.collection(name);
|
||||
return this.mongodb.collection<T>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue