Skip to content

Commit

Permalink
fix: minio client fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jcy0308 committed Aug 30, 2024
1 parent 1d4aa60 commit 3b0b1ed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/kafka/kafka.module.ts
Original file line number Diff line number Diff line change
@@ -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],
})
Expand Down
4 changes: 2 additions & 2 deletions src/kafka/kafka.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}`,
Expand Down
6 changes: 3 additions & 3 deletions src/minio/minio-client.module.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -17,7 +17,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
}),
}),
],
providers: [MinioService],
exports: [MinioService],
providers: [MinioClientService],
exports: [MinioClientService],
})
export class MinioClientModule {}
25 changes: 12 additions & 13 deletions src/minio/minio.service.ts → src/minio/minio-client.service.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
Expand Down

0 comments on commit 3b0b1ed

Please sign in to comment.