import { Job } from 'bullmq';
import { Logger } from '@nestjs/common';
import { QueueJobType } from '../types';
import { ResourceProcessingPipeline } from '@server/models/resource/pipe/resource.pipeline';
import { ImageProcessor } from '@server/models/resource/processor/ImageProcessor';
import { VideoProcessor } from '@server/models/resource/processor/VideoProcessor';
const logger = new Logger('FileProcessorWorker');
const pipeline = new ResourceProcessingPipeline()
    .addProcessor(new ImageProcessor())
    .addProcessor(new VideoProcessor())
export default async function processJob(job: Job<any, any, QueueJobType>) {
    if (job.name === QueueJobType.FILE_PROCESS) {
        console.log(job)
        const { resource } = job.data;
        if (!resource) {
            throw new Error('No resource provided in job data');
        }
        const result = await pipeline.execute(resource);

        return result;
    }
}