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 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-middleware-minio

v3.1.0

Published

An Express middleware that helps you store files in Minio.

Readme

Introduction

This Minio middleware is written for Node.js Express apps to use Minio to store files.

Files can be uploaded to a predefined folder in a predefined bucket in a Minio sever. Once a file has been uploaded successfully, you will be informed of the filename known to Minio for this file. Later on, you can use this filename to download or delete the file.

The Minio middleware also allows you to list all files stored inside the predefined folder in the predefined bucket in Minio.

How to use the package?

First of all, install the package:

npm i express-middleware-minio

Or

yarn add express-middleware-minio

Second, you need to add .env to get it up running, e.g.:

MINIO_ACCESS_KEY=xxx
MINIO_SECRET_KEY=xxx
MINIO_ENDPOINT='192.111.111.131'
MINIO_PORT=9000
MINIO_SECURITY=false
MINIO_BUCKET=manuscripts
MINIO_UPLOADS_FOLDER_NAME=uploads

Then you can use the Minio middleware in your Express application:

Four operations are provided:

  • post
  • get (deprecated)
  • getStream
  • delete
  • list

You can use them the following way:

const expressMinio = require('express-middleware-minio')
console.log(expressMinio.Ops.post)

You can find below an example.

const expressMinio = require('express-middleware-minio')
const minioMiddleware = expressMinio.middleware();

// Upload a file
app.post('/api/files', minioMiddleware({op: expressMinio.Ops.post}), (req, res) => {
  if (req.minio.error) {
    res.status(400).json({ error: req.minio.error })
  } else {
    res.send({ filename: req.minio.post.filename })
  }
})

// List all files
app.get('/api/files',
  minioMiddleware({op: expressMinio.Ops.list}),
  (req, res) => {
    if (req.minio.error) {
      res.status(400).json({ error: req.minio.error })
    } else {
      res.send(req.minio.list)
    }
  }
)

// Download a file
app.get(
  `/api/files/:filename`,
  minioMiddleware({ op: expressMinio.Ops.getStream }),
  (req, res) => {
    if (req.minio.error) {
      res.status(400).json({ error: req.minio.error })
      return
    }

    res.attachment(req.minio.get.originalName)
    req.minio.get.stream.pipe(res);
  },
)

// Delete a file
app.delete('/api/files/:filename',
  minioMiddleware({op: expressMinio.Ops.delete}),
  (req, res) => {
    if (req.minio.error) {
      res.status(400).json({ error: req.minio.error })
    } else {
      res.send(req.minio.delete)
    }
  }
)

Configuration

logger (optional)

By default, console is used for logging. You can override the logger with Node-config.

Here is an example config/default.js:

const logger = require('winston')
require('winston-daily-rotate-file')

logger.add(logger.transports.DailyRotateFile, {
  dirname: './logs',
  filename: 'xpub-epmc.log',
  datePattern: 'YYYY-MM-DD',
  zippedArchive: true,
  maxFiles: '30d',
})

module.exports = {
  logger,
}

Temporary directory (optional and deprecated)

Currently when retrieving a file from Minio via operation get (see above), we download and save it in the local filesystem, and then return it to the client.

This is the directory used to hold the file in the local filesystem. Be default, it is /tmp. You can change it to a different directory if necessary.

Here is an example config/default.js:

module.exports = {
  minioTmpDir: '/tmp'
}

Note: the recommended way is to use operation getStream, which would pipe the stream of the requested file to the client. If you use getStream way, you don't need to set up the temporary directory.