diff --git a/src/kafka/kafka.module.ts b/src/kafka/kafka.module.ts index 2a30111..23c6e21 100644 --- a/src/kafka/kafka.module.ts +++ b/src/kafka/kafka.module.ts @@ -1,10 +1,10 @@ import { Module } from '@nestjs/common'; import { KafkaService } from './kafka.service'; import { PuppeteerModule } from '../puppeteer/puppeteer.module'; -import { MinioModule } from '../minio/minio-client.module'; +import { MinioClientModule } from '../minio/minio-client.module'; @Module({ - imports: [PuppeteerModule, MinioModule], + imports: [PuppeteerModule, MinioClientModule], providers: [KafkaService], exports: [KafkaService], }) diff --git a/src/kafka/kafka.service.ts b/src/kafka/kafka.service.ts index eb5ca10..52cb1f4 100644 --- a/src/kafka/kafka.service.ts +++ b/src/kafka/kafka.service.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Kafka, EachMessagePayload, Consumer } from 'kafkajs'; import { PuppeteerService } from '../puppeteer/puppeteer.service'; -import { MinioService } from '../minio/minio.service'; +import { MinioClientService } from '../minio/minio-client.service'; @Injectable() export class KafkaService implements OnModuleInit, OnModuleDestroy { @@ -16,7 +16,7 @@ export class KafkaService implements OnModuleInit, OnModuleDestroy { constructor( private readonly puppeteerService: PuppeteerService, - private readonly minioService: MinioService, + private readonly minioService: MinioClientService, ) { this.kafka = new Kafka({ clientId: `${process.env.CONSUMER_GROUP}+${process.pid}`, diff --git a/src/minio/minio-client.module.ts b/src/minio/minio-client.module.ts index 9b8f3d3..dbe53dc 100644 --- a/src/minio/minio-client.module.ts +++ b/src/minio/minio-client.module.ts @@ -1,5 +1,5 @@ import { Global, Module } from '@nestjs/common'; -import { MinioService } from './minio.service'; +import { MinioClientService } from './minio-client.service'; import { MinioModule } from 'nestjs-minio-client'; import { ConfigModule, ConfigService } from '@nestjs/config'; @Global() @@ -17,7 +17,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config'; }), }), ], - providers: [MinioService], - exports: [MinioService], + providers: [MinioClientService], + exports: [MinioClientService], }) export class MinioClientModule {} diff --git a/src/minio/minio.service.ts b/src/minio/minio-client.service.ts similarity index 53% rename from src/minio/minio.service.ts rename to src/minio/minio-client.service.ts index 410e863..0ec3b3a 100644 --- a/src/minio/minio.service.ts +++ b/src/minio/minio-client.service.ts @@ -1,19 +1,18 @@ -import { BadRequestException, Injectable, OnModuleInit } from '@nestjs/common'; -import { Client } from 'minio'; +import { BadRequestException, Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import { MinioService } from 'nestjs-minio-client'; @Injectable() -export class MinioService implements OnModuleInit { - private minioClient: Client; - private bucketName = process.env.MINIO_BUCKET_NAME; +export class MinioClientService { + private readonly minioClient; + private readonly bucketName; - onModuleInit() { - this.minioClient = new Client({ - endPoint: process.env.MINIO_END_POINT, - port: parseInt(process.env.MINIO_PORT), - useSSL: true, - accessKey: process.env.MINIO_ACCESS_KEY, - secretKey: process.env.MINIO_PRIVATE_KEY, - }); + constructor( + private readonly configService: ConfigService, + private readonly minioService: MinioService, + ) { + this.minioClient = this.minioService.client; + this.bucketName = this.configService.get('MINIO_BUCKET_NAME'); } async uploadPdf(fileName: string, pdfBuffer: Buffer, headers): Promise {