commit 2 refactor

This commit is contained in:
Boki 2026-10-20 14:35:45 -04:00
parent 588f666943
commit 32e43c9243
310 changed files with 33318 additions and 31189 deletions

View file

@ -1,15 +1,16 @@
import { chromium } from 'playwright';
import type { BrowserContext, Page, Browser as PlaywrightBrowser } from 'playwright';
import type { LoggerLike } from '@stock-bot/logger';
import type { BrowserOptions, NetworkEvent, NetworkEventHandler } from './types';
export class Browser {
private browser?: PlaywrightBrowser;
private contexts: Map<string, BrowserContext> = new Map();
private logger: any;
private logger: LoggerLike;
private options: BrowserOptions;
private initialized = false;
constructor(logger?: any, defaultOptions?: BrowserOptions) {
constructor(logger?: LoggerLike, defaultOptions?: BrowserOptions) {
this.logger = logger || console;
this.options = {
headless: true,

View file

@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, mock } from 'bun:test';
import { SimpleBrowser } from '../src/simple-browser';
import { SimpleBrowser } from './support/simple-browser';
describe('Browser', () => {
let browser: SimpleBrowser;

View file

@ -1,5 +1,5 @@
import type { Page } from 'playwright';
import type { BrowserOptions, ScrapingResult } from './types';
import type { BrowserOptions, ScrapingResult } from '../../src/types';
/**
* Simple browser implementation for testing

View file

@ -2,6 +2,7 @@
* Centralized Proxy Manager - Handles proxy storage, retrieval, and caching
*/
import type { CacheProvider } from '@stock-bot/cache';
import type { LoggerLike } from '@stock-bot/logger';
import type { ProxyInfo, ProxyManagerConfig, ProxyStats } from './types';
export class ProxyManager {
@ -11,10 +12,10 @@ export class ProxyManager {
private lastUpdate: Date | null = null;
private lastFetchTime: Date | null = null;
private isInitialized = false;
private logger: any;
private logger: LoggerLike;
private config: ProxyManagerConfig;
constructor(cache: CacheProvider, config: ProxyManagerConfig = {}, logger?: any) {
constructor(cache: CacheProvider, config: ProxyManagerConfig = {}, logger?: LoggerLike) {
this.cache = cache;
this.config = config;
this.logger = logger || console;
@ -85,7 +86,7 @@ export class ProxyManager {
// Note: We don't increment the index here since getProxy() already does that
const currentIndex = this.proxyIndex > 0 ? this.proxyIndex - 1 : this.proxies.length - 1;
const proxyInfo = this.proxies[currentIndex];
return proxyInfo || null;
}