work on getting close to refactor

This commit is contained in:
Boki 2025-06-22 11:08:26 -04:00
parent 8550b1de57
commit a63ccc96f5
15 changed files with 129 additions and 178 deletions

View file

@ -0,0 +1,53 @@
import {
BaseHandler,
Handler,
Operation,
ScheduledOperation,
type ExecutionContext,
type IServiceContainer
} from '@stock-bot/handlers';
import { fetch, getRandomUserAgent } from '@stock-bot/utils';
@Handler('qm')
export class CeoHandler extends BaseHandler {
constructor(services: IServiceContainer) {
super(services); // Handler name read from @Handler decorator
}
@ScheduledOperation('ceo', '0 */15 * * *', {
priority: 7,
immediately: true,
description: 'Get all CEO symbols and exchanges'
})
async searchCeoChannels(payload: number | undefined, context: ExecutionContext): Promise<unknown> {
const proxy = this.proxy.getProxy();;
let page;
if(payload === undefined) {
page = 1
}else{
page = payload;
}
this.logger.info(`Fetching CEO channels for page ${page} with proxy ${proxy}`);
const result = fetch('https://proxy-detection.stare.gg/all?api_key=bd406bf53ddc6abe1d9de5907830a955', {
method: 'GET',
proxy: proxy,
headers: {
'User-Agent': getRandomUserAgent()
}
})
// const result = fetch('https://api.ceo.ca/api/home?exchange=all&sort_by=symbol&sector=All&tab=companies&page=1')
// Call the session maintenance action
// const { checkSessions } = await import('./actions/session.action');
// return await checkSessions(this);
return ;
}
@Operation('create-session')
async createSession(input: unknown, context: ExecutionContext): Promise<unknown> {
// // Call the individual session creation action
// const { createSingleSession } = await import('./actions/session.action');
// return await createSingleSession(this, input);
return ;
}
}

View file

@ -6,7 +6,6 @@
import type { IServiceContainer } from '@stock-bot/handlers';
import { autoRegisterHandlers } from '@stock-bot/handlers';
import { getLogger } from '@stock-bot/logger';
import { join } from 'path';
// Import handlers for bundling (ensures they're included in the build)
import './qm/qm.handler';
@ -53,14 +52,15 @@ async function manualHandlerRegistration(serviceContainer: any): Promise<void> {
logger.warn('Falling back to manual handler registration');
try {
// Import and register handlers manually
const { QMHandler } = await import('./qm/qm.handler');
const qmHandler = new QMHandler(serviceContainer);
qmHandler.register();
// // Import and register handlers manually
// const { QMHandler } = await import('./qm/qm.handler');
// const qmHandler = new QMHandler(serviceContainer);
// qmHandler.register();
// const { WebShareHandler } = await import('./webshare/webshare.handler');
// const webShareHandler = new WebShareHandler(serviceContainer);
// webShareHandler.register();
const { WebShareHandler } = await import('./webshare/webshare.handler');
const webShareHandler = new WebShareHandler(serviceContainer);
webShareHandler.register();
logger.info('Manual handler registration complete');
} catch (error) {

View file

@ -1,9 +1,6 @@
import {
BaseHandler,
Handler,
Operation,
QueueSchedule,
type ExecutionContext,
type IServiceContainer
} from '@stock-bot/handlers';
@ -13,24 +10,24 @@ export class QMHandler extends BaseHandler {
super(services); // Handler name read from @Handler decorator
}
@Operation('check-sessions')
@QueueSchedule('0 */15 * * *', {
priority: 7,
immediately: true,
description: 'Check and maintain QM sessions'
})
async checkSessions(input: unknown, context: ExecutionContext): Promise<unknown> {
// Call the session maintenance action
const { checkSessions } = await import('./actions/session.action');
return await checkSessions(this);
}
// @Operation('check-sessions')
// @QueueSchedule('0 */15 * * *', {
// priority: 7,
// immediately: true,
// description: 'Check and maintain QM sessions'
// })
// async checkSessions(input: unknown, context: ExecutionContext): Promise<unknown> {
// // Call the session maintenance action
// const { checkSessions } = await import('./actions/session.action');
// return await checkSessions(this);
// }
@Operation('create-session')
async createSession(input: unknown, context: ExecutionContext): Promise<unknown> {
// Call the individual session creation action
const { createSingleSession } = await import('./actions/session.action');
return await createSingleSession(this, input);
}
// @Operation('create-session')
// async createSession(input: unknown, context: ExecutionContext): Promise<unknown> {
// // Call the individual session creation action
// const { createSingleSession } = await import('./actions/session.action');
// return await createSingleSession(this, input);
// }
// @Operation('search-symbols')
// async searchSymbols(_input: unknown, _context: ExecutionContext): Promise<unknown> {