/** * Proxy management routes */ import { Hono } from 'hono'; import { getLogger } from '@stock-bot/logger'; import { queueManager } from '../services/queue.service'; const logger = getLogger('proxy-routes'); export const proxyRoutes = new Hono(); // Proxy management endpoints proxyRoutes.post('/api/proxy/fetch', async (c) => { try { const job = await queueManager.addJob({ type: 'proxy-fetch', service: 'proxy', provider: 'proxy-service', operation: 'fetch-and-check', payload: {}, priority: 5 }); return c.json({ status: 'success', jobId: job.id, message: 'Proxy fetch job queued' }); } catch (error) { logger.error('Failed to queue proxy fetch', { error }); return c.json({ status: 'error', message: 'Failed to queue proxy fetch' }, 500); } }); proxyRoutes.post('/api/proxy/check', async (c) => { try { const { proxies } = await c.req.json(); const job = await queueManager.addJob({ type: 'proxy-check', service: 'proxy', provider: 'proxy-service', operation: 'check-specific', payload: { proxies }, priority: 8 }); return c.json({ status: 'success', jobId: job.id, message: `Proxy check job queued for ${proxies.length} proxies` }); } catch (error) { logger.error('Failed to queue proxy check', { error }); return c.json({ status: 'error', message: 'Failed to queue proxy check' }, 500); } }); // Get proxy stats via queue proxyRoutes.get('/api/proxy/stats', async (c) => { try { const job = await queueManager.addJob({ type: 'proxy-stats', service: 'proxy', provider: 'proxy-service', operation: 'get-stats', payload: {}, priority: 3 }); return c.json({ status: 'success', jobId: job.id, message: 'Proxy stats job queued' }); } catch (error) { logger.error('Failed to queue proxy stats', { error }); return c.json({ status: 'error', message: 'Failed to queue proxy stats' }, 500); } });