work on getting close to refactor
This commit is contained in:
parent
8550b1de57
commit
a63ccc96f5
15 changed files with 129 additions and 178 deletions
53
apps/data-ingestion/src/handlers/ceo/ceo.handler.ts
Normal file
53
apps/data-ingestion/src/handlers/ceo/ceo.handler.ts
Normal 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§or=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 ;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue