huge refactor to remove depenencie hell and add typesafe container

This commit is contained in:
Boki 2025-06-24 09:37:51 -04:00
parent 28b9822d55
commit 843a7b9b9b
148 changed files with 3603 additions and 2378 deletions

View file

@ -282,21 +282,18 @@ export class ProxyManager {
}
const { apiKey, apiUrl } = this.config.webshare;
this.logger.info('Fetching proxies from WebShare API', { apiUrl });
try {
const response = await fetch(
`${apiUrl}proxy/list/?mode=direct&page=1&page_size=100`,
{
method: 'GET',
headers: {
Authorization: `Token ${apiKey}`,
'Content-Type': 'application/json',
},
signal: AbortSignal.timeout(10000), // 10 second timeout
}
);
const response = await fetch(`${apiUrl}proxy/list/?mode=direct&page=1&page_size=100`, {
method: 'GET',
headers: {
Authorization: `Token ${apiKey}`,
'Content-Type': 'application/json',
},
signal: AbortSignal.timeout(10000), // 10 second timeout
});
if (!response.ok) {
throw new Error(`WebShare API request failed: ${response.status} ${response.statusText}`);
@ -370,13 +367,13 @@ export class ProxyManager {
// Fetch proxies on startup if enabled
if (this.config.enabled && this.config.webshare) {
this.logger.info('Proxy fetching is enabled, fetching proxies from WebShare...');
try {
const proxies = await this.fetchWebShareProxies();
if (proxies.length === 0) {
throw new Error('No proxies fetched from WebShare API');
}
await this.updateProxies(proxies);
this.logger.info('ProxyManager initialized with fresh proxies', {
count: proxies.length,
@ -385,10 +382,14 @@ export class ProxyManager {
} catch (error) {
// If proxy fetching is enabled but fails, the service should not start
this.logger.error('Failed to fetch proxies during initialization', { error });
throw new Error(`ProxyManager initialization failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
throw new Error(
`ProxyManager initialization failed: ${error instanceof Error ? error.message : 'Unknown error'}`
);
}
} else {
this.logger.info('ProxyManager initialized without fetching proxies (disabled or not configured)');
this.logger.info(
'ProxyManager initialized without fetching proxies (disabled or not configured)'
);
}
}
}