feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,42 @@
import { Processor, WorkerHost } from '@nestjs/bullmq';
import { Scope } from '@nestjs/common';
import { Job } from 'bullmq';
import { ClsService, UseCls } from 'nestjs-cls';
import { Process } from '@nestjs/bull';
import {
OrganizationBuildQueue,
OrganizationBuildQueueJob,
OrganizationBuildQueueJobPayload,
} from '../Organization.types';
import { BuildOrganizationService } from '../commands/BuildOrganization.service';
@Processor({
name: OrganizationBuildQueue,
scope: Scope.REQUEST,
})
export class OrganizationBuildProcessor extends WorkerHost {
constructor(
private readonly organizationBuildService: BuildOrganizationService,
private readonly clsService: ClsService,
) {
super();
}
@Process(OrganizationBuildQueueJob)
@UseCls()
async process(job: Job<OrganizationBuildQueueJobPayload>) {
console.log('Processing organization build job:', job.id);
this.clsService.set('organizationId', job.data.organizationId);
this.clsService.set('userId', job.data.userId);
try {
await this.organizationBuildService.build(job.data.buildDto);
} catch (e) {
// Unlock build status of the tenant.
await this.organizationBuildService.revertBuildRunJob();
console.error('Error processing organization build job:', e);
throw e; // Re-throw to mark job as failed
}
}
}