Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martinandreev/minio-nestjs-client
A simple NestJS module that wraps the Minio Node.js library in a more familiar way
https://github.com/martinandreev/minio-nestjs-client
minio nest nestjs nodejs typescript
Last synced: 10 days ago
JSON representation
A simple NestJS module that wraps the Minio Node.js library in a more familiar way
- Host: GitHub
- URL: https://github.com/martinandreev/minio-nestjs-client
- Owner: MartinAndreev
- License: mit
- Created: 2022-01-07T16:48:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T21:42:47.000Z (11 months ago)
- Last Synced: 2024-12-15T10:35:12.472Z (2 months ago)
- Topics: minio, nest, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.31 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
NestJS Minio Client
![]()
![main](https://github.com/MartinAndreev/minio-nestjs-client/actions/workflows/test.yml/badge.svg?branch=main)
This is a really simple NestJS module, that lets you initialize the [minio client](https://docs.min.io/docs/javascript-client-api-reference.html)
in a NestJS friendly way and provides a handy way to inject the client.## Change Log
See [Changelog](CHANGELOG.md) for more information.
## Authors
- **Martin Andreev **
## License
Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Installation
To install the module simple run
```bash
npm install minio-nestjs-client
```or
```bash
yarn add minio-nestjs-client
```## Usage
As this is a simple wrapper usage is pretty straigth forward. Just import the MinioModule and initialize it.
There are two ways to do this, a simple config and async config.To use the simple config just:
```typescript
import { MinioModule } from 'minio-nestjs-client';MinioModule.forRoot({
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'Q3AM3UQ867SPQQA43P2F',
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
});
```However, there are times, where configuration if loaded from a service or depends on other providers. This can be achived using the `MinioModule.forRootAsync`.
```typescript
import { MinioModule } from 'minio-nestjs-client';MinioModule.forRootAsync({
useFactory: () =>
new Promise((resolve) => {
resolve({
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'Q3AM3UQ867SPQQA43P2F',
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
});
}),
});
```Here is also an example, that uses the `@nestjs/config`.
```typescript
import { MinioModule, MinioConfig } from 'minio-nestjs-client';MinioModule.forRootAsync({
useFactory: (config) => {
return config.get('config-key');
},
inject: [ConfigService],
import: [ConfigModule],
});
```And to access the client just use the Injection token
```typescript
import { MINIO_CLIENT, MinioClient } from 'minio-nestjs-client';@Injectable()
export class MyService {
public constructor(private readonly client: MinioClient) {}public async doSomethingWithABucket(): Promise {
const bucketExists = await this.client.bucketExists('test');return bucketExists ? 'We have a bucket' : 'We dont have a bucket';
}
}
```## Development
1. Clone the repo
2. Run yarn install```bash
cd minio-nestjs-client
yarn install
```## Running tests
```bash
yarn test
```