Gathering detailed insights and metrics for @nimasfl/nest-minio
Gathering detailed insights and metrics for @nimasfl/nest-minio
Gathering detailed insights and metrics for @nimasfl/nest-minio
Gathering detailed insights and metrics for @nimasfl/nest-minio
npm install @nimasfl/nest-minio
Typescript
Module System
Node Version
NPM Version
TypeScript (93.5%)
JavaScript (6.5%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
7 Stars
45 Commits
4 Forks
1 Watchers
2 Branches
3 Contributors
Updated on Mar 11, 2023
Latest Version
3.0.4
Package Id
@nimasfl/nest-minio@3.0.4
Unpacked Size
49.52 kB
Size
13.25 kB
File Count
51
NPM Version
8.5.5
Node Version
16.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
5
7
1
This package developed to handle minio requests in nestjs application as easy as possible.
Install the package:
npm install @nimasfl/nest-minio --save
First you should register the module in your main module for example app.module
. since it's a global package, it will be available in every other module you're using.
1// src/app.module.ts 2 3@Module({ 4 imports: [ 5 MinioModule.register( 6 { 7 accessKey: process.env.MINIO_ACCESS_KEY, 8 endPoint: process.env.MINIO_HOST, 9 port: +process.env.MINIO_PORT, 10 secretKey: process.env.MINIO_SECRET_KEY, 11 useSSL: false, 12 }, 13 { 14 directAccessPrefix: 'http://localhost:9000', // OPTIONAL 15 compression: { 16 enabled: true, 17 original: true, 18 medium: true, 19 small: true, 20 smallSize: 128, 21 baseDim: 1024, 22 }, 23 }, 24 ), 25 ], 26})
MinioModule
takes 2 arguments as input.
The first is the configuration which you can use ClientOptions
interface from minio package to write a config file for this module.
The second one is custom options which will be described in another section.
Once you did last part you only need to inject MinioService
class in your service files in order to make use of this module.
1// src/example/example.service.ts 2 3import { MinioService } from '@nimasfl/nest-minio'; 4 5@Injectable() 6export class FileUploadService { 7 constructor(private minioService: MinioService) {}
Note that in following examples BufferedFile
, MinioMimeType
and MinioService
classes are imported from @nimasfl/nest-minio
All the configuration needed to startup this module, is referenced in official minio javascript API reference.
For now we have directAccessPrefix and compression options.
directAccessPrefix
is for the scenario where you need absolute url of the file.
compression
only applies to image/png
and image/jpeg
mime types and you can also mention small size that you desired
this option enables you to get the absolute url when uploading a file, or use this absolute url when you want to get a file.
For example when using this module the response of upload method will be like
1{ 2 "isFileUploaded": true, 3 "url": "http://localhost:9000/test/f4fc1cc1fa377f1b80176b64ccf92ff7.png", 4 "smallUrl": null, 5 "largeUrl": null 6}
instead of
1{ 2 "isFileUploaded": true, 3 "url": "/test/f4fc1cc1fa377f1b80176b64ccf92ff7.png", 4 "smallUrl": null, 5 "largeUrl": null 6}
Then you can use this stored url to the get method.
Whether you are using this option or not, any string that exists in the url response of upload method can be used to fetch that file using the get method.
following file is a controller file example that uses every method of this module.
1 2import { Response } from 'express'; 3import { 4 Controller, 5 Delete, 6 Get, 7 Header, 8 Param, 9 Post, 10 Res, 11 UploadedFile, 12} from '@nestjs/common'; 13import { 14 BufferedFile, 15 DeleteFileResponse, 16 MinioMimeType, 17 MinioService, 18 Upload, 19 UploadFileResponse, 20} from '@nimasfl/nest-minio'; 21 22@Controller('/uploads') 23export class FileUploadController { 24 constructor(private minioService: MinioService) {} 25 26 @Post() 27 // Upload decorator configures swagger and uses nest's interceptor to get the file by its name 28 @Upload('image') 29 async uploadSingle( 30 @UploadedFile() image: BufferedFile, 31 ): Promise<UploadFileResponse> { 32 // Third argument of this method (validator) is optional and wont check anything if its not sent. 33 return this.minioService.upload(image, 'testBucket', { 34 maxSize: 35, // Maximum size allowed to upload. 35 validMimes: [MinioMimeType.PNG, MinioMimeType.JPEG], // Allowed file types tp be uploaded. 36 }); 37 } 38 39 @Delete('/:fileName') 40 async delete( 41 @Param('fileName') fileName: string, 42 ): Promise<DeleteFileResponse> { 43 // Second argument of this method (bucketValidator) is optional. 44 // you can check whether if the requested file is in the required bucket or not. 45 return this.minioService.delete(fileName, 'testBucket'); 46 } 47 48 @Get('/:fileName') 49 // You can set Content-Type based on the file you're trying to fetch. 50 @Header('Content-Type', 'application/octet-stream') 51 async get(@Param('fileName') fileName: string, @Res() res: Response) { 52 // Third argument of this method (bucketValidator) is optional. 53 // you can check whether if the requested file is in the required bucket or not. 54 return this.minioService.get(res, fileName, 'testBucket'); 55 } 56} 57
Just remember in the minioService.get()
method you need to pass the raw response
of the request (imported from express
) to the method. So if you want to use @Next
decorator
in this controller, you should use it wisely as NestJS said in its docs:
Nest detects when the handler is using either @Res() or @Next(), indicating you have chosen the library-specific option. If both approaches are used at the same time, the Standard approach is automatically disabled for this single route and will no longer work as expected. To use both approaches at the same time (for example, by injecting the response object to only set cookies/headers but still leave the rest to the framework), you must set the passthrough option to true in the @Res({ passthrough: true }) decorator.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More