npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-minio-module

v2.1.1

Published

The better Nest.js Minio client module

Readme

Nest.js MinIO Module

A tiny package to make a bridge between Nest.js DI system and MinIO client instance.

Table of Contents

Installation

You can install nestjs-minio-module using npm or yarn:

npm i nestjs-minio-module minio --save
# or
yarn add nestjs-minio-module minio

The package also requires it's peer dependencies to be installed. Likely you already have @nestjs/common installed - that is the reason why it is not specified in the snippet above.

Usage

You may register MinioModule synchronously as follows.

import { Module } from '@nestjs/common';
import { MinioModule } from 'nestjs-minio-module';

@Module({
imports: [
    MinioModule.register({
      endPoint: '127.0.0.1',
      port: 1337,
      useSSL: true,
      accessKey: 'minio_access_key',
      secretKey: 'minio_secret_key'
    })
})
export class AppModule {}

MinioModule may also be registered asynchronously with a factory or a value. Let's imagine we are using a ConfigService and want to get MinIO options from it. We may do it as follows:

import { Module } from '@nestjs/common';
import { MinioModule } from 'nestjs-minio-module';
import { ConfigModule, ConfigService } from '<config_module>';

@Module({
imports: [
    MinioModule.registerAsync({
        imports: [ConfigModule],
        inject: [ConfigService],
        useFactory: (configService: ConfigService) => configService.get('minio'),
    }),
})
export class AppModule {}

When registered, MinioService may be injected into Nest.js injectables as usual:

import { Injectable } from "@nestjs/common";
import { MinioService } from "nestjs-minio-module";

@Injectable()
export class SomeService {
  constructor(private readonly minioService: MinioService) {}

  async listAllBuckets() {
    return this.minioService.listBuckets();
  }
}

MinioService instance exposes all JavaScript MinIO Client methods as it's own. You may find SDK specification here.

Extending MinioService

You may create your own services extending from MinioService. It is a generic class so you may specify your own options type.

import { Injectable } from "@nestjs/common";
import { MinioService } from "nestjs-minio-module";

import type { MinioModuleOptions } from "nestjs-minio-module";

type S3Options = {
  publicEndPoint?: string;
} & MinioModuleOptions;

@Injectable()
export class S3Service extends MinioService<S3Options> {
  public constructUrl(bucket: string, usePublicUrl: boolean): string {
    const protocol = this.options.useSSL ? "https:" : "http:";

    return usePublicUrl && this.options.publicEndPoint
      ? `${protocol}//${bucket}.${this.options.publicEndPoint}/`
      : `${protocol}//${this.options.endPoint}/${bucket}/`;
  }
}

In case if you need to create a custom constructor you should not forget to pass options to the superclass. You may inject options using MINIO_OPTIONS symbol provided and exported from the module.

import { Injectable, Inject } from "@nestjs/common";
import { MinioService, MINIO_OPTIONS } from "nestjs-minio-module";

import type { MinioModuleOptions } from "nestjs-minio-module";

type S3Options = {
  publicEndPoint?: string;
} & MinioModuleOptions;

@Injectable()
export class S3Service extends MinioService<S3Options> {
  constructor(
    @Inject(MINIO_OPTIONS) options: S3Options /*, additional dependencies */
  ) {
    super(options);
  }
}

Comparison to other implementations

You may ask: how is this package different from a few other implementations of MinIO client in Nest.js?

Firstly, this package properly specifies it's peer dependencies. This means you don't get duplicate packages in your node_modules making the package smaller and as a bonus have support for a greater variety of versions.

Secondly, nestjs-minio-module properly exposes MinIO interface through a service, rather than a service field or a separate injectable.

Thirdly, this package allows you to create multiple instances of MinioModule in different scopes. You may have a module dedicated to accessing a MinIO instance in the same kubernetes container and another module accessing a remote S3 object storage.

And adjacent to the last point - this package is very easy to extend. It provides both generic types for its service and a symbol for accessing exported options provider.

Contributing

Feel free to send any suggestions in GitHub issues or open a Pull Request with your feature.

License

MIT