Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/svtslv/nestjs-minio
Minio module for NestJS
https://github.com/svtslv/nestjs-minio
minio nest nestjs s3
Last synced: 2 months ago
JSON representation
Minio module for NestJS
- Host: GitHub
- URL: https://github.com/svtslv/nestjs-minio
- Owner: svtslv
- Created: 2020-03-11T20:01:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-28T03:21:45.000Z (about 1 year ago)
- Last Synced: 2024-11-04T01:05:33.272Z (2 months ago)
- Topics: minio, nest, nestjs, s3
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NestJS Minio
## Table of Contents
- [Description](#description)
- [Installation](#installation)
- [Examples](#examples)
- [License](#license)## Description
Integrates Minio with Nest## Installation
```bash
npm install @svtslv/nestjs-minio minio
``````bash
npm install -D @types/minio
```You can also use the interactive CLI
```sh
npx nestjs-modules
```## Examples
```bash
docker run \
-p 9000:9000 \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=password \
minio/minio server /data
```### MinioModule.forRoot(options, connection?)
```ts
import { Module } from '@nestjs/common';
import { MinioModule } from '@svtslv/nestjs-minio';
import { AppController } from './app.controller';@Module({
imports: [
MinioModule.forRoot({
config: {
// url: 'http://minio:password@localhost:9000',
accessKey: 'minio',
secretKey: 'password',
endPoint: 'localhost',
port: 9000,
useSSL: false,
},
}),
],
controllers: [AppController],
})
export class AppModule {}
```### MinioModule.forRootAsync(options, connection?)
```ts
import { Module } from '@nestjs/common';
import { MinioModule } from '@svtslv/nestjs-minio';
import { AppController } from './app.controller';@Module({
imports: [
MinioModule.forRootAsync({
useFactory: () => ({
config: {
// url: 'http://minio:password@localhost:9000',
accessKey: 'minio',
secretKey: 'password',
endPoint: 'localhost',
port: 9000,
useSSL: false,
},
}),
}),
],
controllers: [AppController],
})
export class AppModule {}
```### InjectMinioClient(connection?)
```ts
import { Controller, Get, } from '@nestjs/common';
import { InjectMinioClient, MinioClient } from '@svtslv/nestjs-minio';@Controller()
export class AppController {
constructor(
@InjectMinioClient() private readonly minioClient: MinioClient,
) {}@Get()
async getHello() {
if(!await this.minioClient.bucketExists('bucket2')) {
await this.minioClient.makeBucket('bucket2', '');
}return await this.minioClient.listBuckets()
}
}
```## License
MIT