Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/biomousavi/nest-minio
A simple Minio wrapper for Nest.js .
https://github.com/biomousavi/nest-minio
minio nestjs
Last synced: 4 days ago
JSON representation
A simple Minio wrapper for Nest.js .
- Host: GitHub
- URL: https://github.com/biomousavi/nest-minio
- Owner: biomousavi
- Created: 2022-12-24T16:09:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-24T17:44:51.000Z (about 2 years ago)
- Last Synced: 2024-10-06T12:37:17.684Z (3 months ago)
- Topics: minio, nestjs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/minio-nestjs
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nest.js MinIO Module
A simple [Minio](https://min.io/) wrapper for [Nest.js](https://nestjs.com) .## Installation
```bash
npm i minio-nestjs
# or
yarn add minio-nestjs
```## Module setup
Register module synchronously :
```typescript
import { Module } from '@nestjs/common';
import { MinioModule } from 'minio-nestjs';@Module({
imports: [
MinioModule.register({
endPoint: '127.0.0.1',
port: 9000,
useSSL: false,
accessKey: 'biomousavi',
secretKey: 'yourStrongPassword',
}),
],
})
export class AppModule {}
```Asynchronous registration:
```typescript
import { Module } from '@nestjs/common';
import { MinioModule } from 'minio-nestjs';
import { ConfigModule, ConfigService } from '@nestjs/config';@Module({
imports: [
ConfigModule.forRoot({ envFilePath: '.env' }),
MinioModule.registerAsync({
isGlobal: true,
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return {
port: +configService.get('MINIO_PORT'),
endPoint: configService.get('MINIO_ENDPOINT'),
accessKey: configService.get('MINIO_ROOT_USER'),
secretKey: configService.get('MINIO_ROOT_PASSWORD'),
useSSL: configService.get('NODE_ENV') === 'production' ? true : false,
};
},
}),
],
})
export class AppModule {}
```## Module usage
Now you have access to Minio client:
```typescript
import { Injectable } from '@nestjs/common';
import { MinioService } from 'minio-nestjs';@Injectable()
export class FileService {
constructor(private readonly minioService: MinioService) {}async getBuckets() {
return await this.minioService.listBuckets();
}
}
```