Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/djedlajn/nestjs-minio-client
Minio client sdk for NestJS
https://github.com/djedlajn/nestjs-minio-client
minio minio-client-sdk nestjs typescript
Last synced: about 2 months ago
JSON representation
Minio client sdk for NestJS
- Host: GitHub
- URL: https://github.com/djedlajn/nestjs-minio-client
- Owner: djedlajn
- License: mit
- Created: 2019-12-18T13:53:56.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-29T21:48:26.000Z (6 months ago)
- Last Synced: 2024-11-14T13:46:56.183Z (2 months ago)
- Topics: minio, minio-client-sdk, nestjs, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nestjs-minio-client
- Size: 744 KB
- Stars: 37
- Watchers: 5
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Nestjs Minio Client
Minio client for NestJs.
## Features
- Configure and connect to Minio instance
## Prerequisites
- NestJS version 9 or later.
### Installation
**Yarn**
```bash
yarn add nestjs-minio-client
```**NPM**
```bash
npm install nestjs-minio-client --save
```### Getting Started
To use Minio client we need to register module for example in `app.module.ts`
```ts
import { Module } from '@nestjs/common';
import { MinioModule } from 'nestjs-minio-client';@Module({
imports: [
MinioModule.register({
endPoint: '127.0.0.1',
port: 9000,
useSSL: false,
accessKey: 'minio_access_key',
secretKey: 'minio_secret_key'
})
})export class AppModule {}
```If you are using the `@nestjs/config` package from nest, you can use the `ConfigModule` using the `registerAsync()` function to inject your environment variables like this in your custom module:
```ts
import { Module } from '@nestjs/common';
import { MinioModule } from 'nestjs-minio-client';
import { ConfigModule, ConfigService } from '@nestjs/config';@Module({
imports: [
MinioModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => {
return {
endPoint: config.get('MINIO_ENDPOINT'),
port: parseInt(config.get('MINIO_PORT')),
useSSL: false,
accessKey: config.get('MINIO_ACCESS_KEY'),
secretKey: config.get('MINIO_SECRET_KEY'),
};
},
}),
],
providers: [MinioClientService],
exports: [MinioClientService],
})
export class MinioClientModule {}
```After the registration connection to minio instance should be completed and ready for usage.
Example usage in service.
```ts
import { Injectable } from '@nestjs/common';
import { MinioService } from 'nestjs-minio-client';@Injectable()
export class ContentService {
constructor(private readonly minioService: MinioService) {}async listAllBuckets() {
return this.minioService.client.listBuckets();
}
}
```For full Client API see Minio Javascript SDK reference [here](https://docs.min.io/docs/javascript-client-api-reference.html)
---