import { Queue } from 'bullmq';
import { getRedis } from './redis.js';

export interface BuildJobData {
  buildId: string;
  serverId: string;
  orgId: string;
  prompt: string;
  version: number;
  slug: string;
  serverName: string;
  secrets: Record<string, string>;
  previewId?: string;
}

let queue: Queue<BuildJobData> | null = null;

export function getBuildQueue(): Queue<BuildJobData> {
  if (!queue) {
    queue = new Queue<BuildJobData>('build', { connection: getRedis() });
  }
  return queue;
}
