123456789101112131415161718192021222324252627282930313233343536373839 |
- import { InjectQueue } from '@nestjs/bull';
- import { Injectable } from '@nestjs/common';
- import { Queue } from 'bull';
- import { randomUUID } from 'crypto';
- import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
- @Injectable()
- export class AssetOptimizeService {
- constructor(@InjectQueue('optimize') private optimizeQueue: Queue) {}
- public async resizeImage(savedAsset: AssetEntity) {
- const job = await this.optimizeQueue.add(
- 'resize-image',
- {
- savedAsset,
- },
- { jobId: randomUUID() },
- );
- return {
- jobId: job.id,
- };
- }
- public async getVideoThumbnail(savedAsset: AssetEntity, filename: string) {
- const job = await this.optimizeQueue.add(
- 'get-video-thumbnail',
- {
- savedAsset,
- filename,
- },
- { jobId: randomUUID() },
- );
- return {
- jobId: job.id,
- };
- }
- }
|