Initial BizOne portal setup

This commit is contained in:
2026-05-11 11:36:33 +07:00
commit 57017dd397
249 changed files with 41305 additions and 0 deletions

View File

@ -0,0 +1,42 @@
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import type { Job as BullJob, Worker } from 'bullmq';
import { JobsService } from '../jobs/jobs.service';
import { RedisQueueService } from '../jobs/redis-queue.service';
import { WebhooksService } from './webhooks.service';
@Injectable()
export class WebhookWorkerService implements OnModuleInit, OnModuleDestroy {
private worker: Worker | null = null;
constructor(
private readonly jobsService: JobsService,
private readonly redisQueueService: RedisQueueService,
private readonly webhooksService: WebhooksService,
) {}
onModuleInit() {
this.worker = this.redisQueueService.createWorker(
'webhooks',
async (job: BullJob<{ dbJobId?: string }>) => {
const dbJobId = job.data?.dbJobId;
if (!dbJobId) {
throw new Error('Redis webhook job missing dbJobId');
}
const claimed = await this.jobsService.markProcessing(dbJobId);
if (!claimed) {
return;
}
await this.webhooksService.processJob(dbJobId);
},
);
}
async onModuleDestroy() {
if (this.worker) {
await this.worker.close();
this.worker = null;
}
}
}