1.0.0 • Published 1 year ago

@mahyar-kd/nestjs-minio v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Description

This's a nest-minio module for Nest. This quickstart guide will show you how to install the client SDK and execute an example JavaScript program. For a complete list of APIs and examples, please take a look at the JavaScript Client API Reference documentation.

This document assumes that you have a working nodejs setup in place.

Installation

$ npm i --save @mahyar--kd/nestjs-minio
or
$ yarn add @mahyar--kd/nestjs-minio

Initialize MinIO Client

You need five items in order to connect to MinIO object storage server.

ParamsDescription
endPointURL to object storage service.
portTCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs.
accessKeyAccess key is like user ID that uniquely identifies your account.
secretKeySecret key is the password to your account.
useSSLSet this value to 'true' to enable secure (HTTPS) access

Provide the credentials for minio module by importing it as :

import { Module } from '@nestjs/common';
import { NestMinioClientController } from './nest-minio-client.controller';
import { MinioModule } from '@mahyar--kd/nestjs-minio';
import { ConfigService } from '@nestjs/config';


@Module({
  controllers: [NestMinioClientController],
  imports: [
    MinioModule.forRootAsync({
      imports: [],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        endPoint: configService.get('minio.endpoint'),
        port: configService.get('minio.port'),
        accessKey: configService.get('minio.accessKey'),
        secretKey: configService.get('minio.secretKey'),
        useSSL: configService.get('minio.useSSL'),
        defaultBucket: configService.get('minio.bucket'),
      }),
    }),
  ],
})
export class NestMinioClientModule {}

Then you can use it in the service by injecting it in the service as:

 constructor(
    @Inject(MINIO_CONNECTION)
    private readonly minioService: MinioService,
) {}
1.0.0

1 year ago