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

@luoluopay/egg-minio

v1.0.0

Published

MinIO plugin for Egg.js

Downloads

12

Readme

egg-minio

在 Egg.js 中快速使用 MinIO 客户端的插件。

安装

npm i egg-minio

在 Egg 项目中启用

config/plugin.js 中添加:

exports.minio = {
  enable: true,
  package: 'egg-minio',
};

TypeScript 模板项目可在 config/plugin.ts 中这样写:

import { EggPlugin } from 'egg';

const plugin: EggPlugin = {
  minio: {
    enable: true,
    package: 'egg-minio',
  },
};

export default plugin;

配置

config/config.default.js 中添加:

单客户端模式

exports.minio = {
  client: {
    endPoint: '127.0.0.1',
    port: 9000,
    useSSL: false,
    accessKey: 'minioadmin',
    secretKey: 'minioadmin',
    region: 'us-east-1',
  },
};

TypeScript 模板项目可在 config/config.default.ts 中这样写:

import { EggAppConfig, PowerPartial } from 'egg';

export default () => {
  const config = {} as PowerPartial<EggAppConfig>;

  config.minio = {
    client: {
      endPoint: '127.0.0.1',
      port: 9000,
      useSSL: false,
      accessKey: 'minioadmin',
      secretKey: 'minioadmin',
      region: 'us-east-1',
    },
  };

  return config;
};

多客户端模式

exports.minio = {
  clients: {
    default: {
      endPoint: '127.0.0.1',
      port: 9000,
      useSSL: false,
      accessKey: 'minioadmin',
      secretKey: 'minioadmin',
      region: 'us-east-1',
    },
    backup: {
      endPoint: '127.0.0.1',
      port: 9001,
      useSSL: false,
      accessKey: 'minioadmin',
      secretKey: 'minioadmin',
      region: 'us-east-1',
    },
  },
};

使用示例

Controller 中上传文件

// app/controller/upload.js
'use strict';

const Controller = require('egg').Controller;

class UploadController extends Controller {
  async putObject() {
    const { ctx, app } = this;
    const stream = await ctx.getFileStream();
    const bucketName = 'demo-bucket';
    const objectName = stream.filename;

    await app.minio.putObject(bucketName, objectName, stream);
    ctx.body = { success: true, objectName };
  }
}

module.exports = UploadController;

多客户端获取方式

const backupClient = app.getMinio('backup');

挂载到 Application 的属性

  • app.minio: 默认 MinIO 客户端(单客户端时为唯一客户端;多客户端时为首个客户端)
  • app.minioClients: 多客户端映射对象(仅多客户端模式下存在)
  • app.getMinio(name): 获取指定名称客户端(仅多客户端模式下存在)

安装后 TypeScript 会自动识别 app.minioapp.minioClientsapp.getMinio 的类型定义。

License

MIT