proxy-auto-ts
Version:
A comprehensive TypeScript library for automatic proxy management with validation, rotation, and intelligent selection
44 lines โข 1.69 kB
JavaScript
import { ProxyManager } from "./lib.js";
// Simple test utility that won't hang
async function simpleTest() {
console.log("๐งช Simple Proxy Test");
const proxyManager = new ProxyManager();
await proxyManager.initialize();
const proxyCount = await proxyManager.getProxyCount();
console.log(`๐ Loaded ${proxyCount} proxies`);
// Set a short timeout for testing
const testManager = new ProxyManager({
timeout: 5000,
validationTimeout: 3000
});
await testManager.initialize();
try {
// Test with very limited retries
console.log(`\n๐ Testing with limited retries (max 3)...`);
const result = await testManager.fetchWithProxy("https://httpbin.org/ip", 3);
console.log(`โ
Working proxy found: ${result.proxy}`);
console.log(`๐ Your IP: ${JSON.stringify(result.data)}`);
console.log(`โฑ๏ธ Latency: ${result.latency}ms`);
}
catch (error) {
console.log(`โ ๏ธ No working proxies found in first 3 attempts: ${error.message}`);
}
// Test stats
console.log(`\n๐ Library statistics...`);
const stats = await proxyManager.getStats();
console.log(`๐ Total proxies: ${stats.totalProxies}`);
console.log(`๐ Proxy list path: ${stats.proxyListPath}`);
console.log(`โ๏ธ Timeout: ${stats.config.timeout}ms`);
console.log(`\n๐ Test completed!`);
}
// Run the test
simpleTest()
.then(() => {
console.log(`\nโ
All tests completed successfully!`);
process.exit(0);
})
.catch((error) => {
console.error(`\nโ Test failed:`, error.message);
process.exit(1);
});
//# sourceMappingURL=simple-test.js.map