# minio-nestjs-client

> A simple NestJS module that wraps the Minio Node.js library in a more familiar way

Latest version **1.0.7** (published 2022-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install minio-nestjs-client
pnpm add minio-nestjs-client
yarn add minio-nestjs-client
bun add minio-nestjs-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-05-20 |
| First published | 2022-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Martin Andreev |
| Maintainers | mandreev |
| Keywords | minio, nestjs, s3 |

## Links

- npm: https://www.npmjs.com/package/minio-nestjs-client
- Repository: https://github.com/MartinAndreev/minio-nestjs-client
- Homepage: https://github.com/MartinAndreev/minio-nestjs-client#readme
- Issues: https://github.com/MartinAndreev/minio-nestjs-client/issues
- npm.io page: https://npm.io/package/minio-nestjs-client

## Dependencies (2)

- [minio](https://npm.io/package/minio.md) ^7.0.28
- [@types/minio](https://npm.io/package/@types/minio.md) ^7.0.13

## Recent versions

- 1.0.7 (latest) — 2022-05-20
- 1.0.5 — 2022-01-07
- 1.0.4 — 2022-01-07
- 1.0.3 — 2022-01-07
- 1.0.2 — 2022-01-07
- 1.0.1 — 2022-01-07
- 1.0.0 — 2022-01-07

## README

<div align="center">
  <a href="http://nestjs.com/" target="_blank">
    <img src="https://nestjs.com/img/logo_text.svg" width="300" alt="Nest Logo" />
  </a>
</div>

<h3 align="center">NestJS Minio Client</h3>

<div align="center">
  <a href="https://nestjs.com" target="_blank">
    <img src="https://img.shields.io/badge/built%20with-NestJs-red.svg" alt="Built with NestJS">
  </a>

![main](https://github.com/MartinAndreev/minio-nestjs-client/actions/workflows/test.yml/badge.svg?branch=main)

</div>

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 <martin.andreev92@gmail.com>**

## 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<MinioConfig>('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<string> {
    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
```

---
_Source: https://npm.io/package/minio-nestjs-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
