28 lines
874 B
TypeScript
28 lines
874 B
TypeScript
import { BullModule } from "@nestjs/bullmq";
|
|
import { Module, OnModuleInit } from "@nestjs/common";
|
|
|
|
import { QUOTA_SYNC_QUEUE } from "./constants";
|
|
import { QuotaSyncProcessor } from "./queue/quota-sync.processor";
|
|
import { QuotaSyncService } from "./services/quota-sync.service";
|
|
import { MailServerModule } from "../mail-server/mail-server.module";
|
|
|
|
@Module({
|
|
imports: [
|
|
MailServerModule,
|
|
BullModule.registerQueue({
|
|
name: QUOTA_SYNC_QUEUE.QUEUE_NAME,
|
|
prefix: QUOTA_SYNC_QUEUE.QUEUE_PREFIX,
|
|
}),
|
|
],
|
|
providers: [QuotaSyncService, QuotaSyncProcessor],
|
|
exports: [QuotaSyncService],
|
|
})
|
|
export class QuotaSyncModule implements OnModuleInit {
|
|
constructor(private readonly quotaSyncService: QuotaSyncService) {}
|
|
|
|
async onModuleInit() {
|
|
// Setup the cron job when the module initializes
|
|
await this.quotaSyncService.setupCronJob();
|
|
}
|
|
}
|