import { Hono } from 'hono';
import type { IServiceContainer } from '@stock-bot/handlers';
import { getLogger } from '@stock-bot/logger';

const logger = getLogger('queue-routes');

export function createQueueRoutes(container: IServiceContainer) {
  const queue = new Hono();

  // Queue status endpoint
  queue.get('/status', async c => {
    try {
      const queueManager = container.queue;
      if (!queueManager) {
        return c.json({ status: 'error', message: 'Queue manager not available' }, 503);
      }

      const globalStats = await queueManager.getGlobalStats();

      return c.json({
        status: 'success',
        data: globalStats,
        message: 'Queue status retrieved successfully',
      });
    } catch (error) {
      logger.error('Failed to get queue status', { error });
      return c.json({ status: 'error', message: 'Failed to get queue status' }, 500);
    }
  });

  return queue;
}
