@aios-medical/bullmq-dashboard-express

中文文档
1.0.2发布于 2026/06/06MITTypeScriptCommonJS近 30 天下载 1896

Express.js server adapter for the aios bullmq dashboard.

原始使用文档
文档目录18 节
  1. Installation
  2. Overview
  3. Usage
  4. Basic Setup
  5. With Bull (Legacy)
  6. Multiple Queues
  7. With Authentication
  8. Custom Middleware
  9. API Reference
  10. ExpressAdapter
  11. Configuration
  12. Advanced Usage
  13. Nested Routes
  14. Custom Error Handling
  15. Multiple Instances
  16. Dependencies
  17. License
  18. Related Packages

@aios-medical/bullmq-dashboard-express

Express.js server adapter for the AIOS BullMQ Dashboard.

AIOS BullMQ Dashboard overview

Installation

npm install @aios-medical/bullmq-dashboard-express
# or
yarn add @aios-medical/bullmq-dashboard-express
# or
pnpm add @aios-medical/bullmq-dashboard-express

Overview

This package provides an Express.js adapter for serving the AIOS BullMQ Dashboard. It handles routing, middleware integration, and serves the static UI assets.

Usage

Basic Setup

import express from 'express';
import { createDashboard } from '@aios-medical/bullmq-dashboard-api';
import { BullMQAdapter } from '@aios-medical/bullmq-dashboard-api/bullMQAdapter';
import { ExpressAdapter } from '@aios-medical/bullmq-dashboard-express';
import { Queue } from 'bullmq';

const app = express();

// Create your BullMQ queue
const queue = new Queue('my-queue', { 
  connection: { host: 'localhost', port: 6379 } 
});

// Create the Express adapter
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/queues');

// Create the dashboard
createDashboard({
  queues: [new BullMQAdapter(queue)],
  serverAdapter,
  options: {
    uiConfig: {
      title: 'My Queue Dashboard',
      subtitle: 'Production',
    },
  },
});

// Mount the dashboard
app.use('/admin/queues', serverAdapter.getRouter());

app.listen(3000, () => {
  console.log('Dashboard running on http://localhost:3000/admin/queues');
});

With Bull (Legacy)

import express from 'express';
import { createDashboard } from '@aios-medical/bullmq-dashboard-api';
import { BullAdapter } from '@aios-medical/bullmq-dashboard-api/bullAdapter';
import { ExpressAdapter } from '@aios-medical/bullmq-dashboard-express';
import Queue from 'bull';

const app = express();

const queue = new Queue('my-queue', { 
  redis: { host: 'localhost', port: 6379 } 
});

const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/queues');

createDashboard({
  queues: [new BullAdapter(queue)],
  serverAdapter,
  options: {
    uiConfig: {
      title: 'My Queue Dashboard',
    },
  },
});

app.use('/admin/queues', serverAdapter.getRouter());

app.listen(3000);

Multiple Queues

const emailQueue = new Queue('emails', { connection: { host: 'localhost', port: 6379 } });
const reportQueue = new Queue('reports', { connection: { host: 'localhost', port: 6379 } });

const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/queues');

createDashboard({
  queues: [
    new BullMQAdapter(emailQueue, { displayName: 'Email Queue' }),
    new BullMQAdapter(reportQueue, { displayName: 'Report Queue' }),
  ],
  serverAdapter,
  options: {
    uiConfig: {
      title: 'Production Queues',
    },
  },
});

app.use('/admin/queues', serverAdapter.getRouter());

With Authentication

import basicAuth from 'express-basic-auth';

const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/queues');

createDashboard({
  queues: [new BullMQAdapter(queue)],
  serverAdapter,
  options: {
    uiConfig: {
      title: 'Protected Dashboard',
    },
  },
});

// Add authentication middleware
app.use('/admin/queues', basicAuth({
  challenge: true,
  users: { admin: process.env.DASHBOARD_PASSWORD || 'secret' },
}));

app.use('/admin/queues', serverAdapter.getRouter());

Custom Middleware

You can add any Express middleware before mounting the dashboard:

const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/queues');

// Rate limiting
import rateLimit from 'express-rate-limit';

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100 // limit each IP to 100 requests per windowMs
});

app.use('/admin/queues', limiter);

// CORS
import cors from 'cors';
app.use('/admin/queues', cors());

// Mount dashboard
app.use('/admin/queues', serverAdapter.getRouter());

API Reference

ExpressAdapter

The main class for configuring the Express adapter.

Constructor

constructor()

Creates a new ExpressAdapter instance with an internal Express app.

Methods

setBasePath(path: string)

Sets the base path for the dashboard routes.

serverAdapter.setBasePath('/admin/queues');
setStaticPath(staticsRoute: string, staticsPath: string)

Configures static file serving for UI assets.

serverAdapter.setStaticPath('/static', '/path/to/dist/static');
setViewsPath(viewPath: string)

Sets the views path for EJS templates.

serverAdapter.setViewsPath('/path/to/dist');
setErrorHandler(handler: (error: Error) => ControllerHandlerReturnValue)

Sets the error handler for API routes.

serverAdapter.setErrorHandler((error) => {
  return {
    status: 500,
    body: { error: error.message }
  };
});
setQueues(queueRegistry: QueueRegistry)

Sets the queue registry (called automatically by createDashboard).

serverAdapter.setQueues(queueRegistry);
setUIConfig(config: UIConfig)

Sets the UI configuration (called automatically by createDashboard).

serverAdapter.setUIConfig({
  title: 'My Dashboard',
  subtitle: 'Production',
});
getRouter()

Returns the Express router to be mounted in your app.

app.use('/admin/queues', serverAdapter.getRouter());

Configuration

The adapter is configured through the createDashboard function from the API package. All UI configuration is passed through the options.uiConfig parameter:

createDashboard({
  queues: [new BullMQAdapter(queue)],
  serverAdapter,
  options: {
    uiConfig: {
      title: 'My Dashboard',
      subtitle: 'Production',
      environment: {
        label: 'Production',
        color: '#ef4444',
      },
      pollingInterval: {
        forceInterval: 5000,
      },
      miscLinks: [
        { text: 'Docs', url: 'https://docs.example.com' },
      ],
      hideRedisDetails: false,
    },
  },
});

Advanced Usage

Nested Routes

You can nest the dashboard under existing routes:

const apiRouter = express.Router();
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/dashboard');

createDashboard({
  queues: [new BullMQAdapter(queue)],
  serverAdapter,
});

apiRouter.use('/dashboard', serverAdapter.getRouter());
app.use('/api/v1', apiRouter);

// Dashboard available at /api/v1/dashboard

Custom Error Handling

serverAdapter.setErrorHandler((error) => {
  console.error('Dashboard error:', error);
  
  return {
    status: 500,
    body: {
      error: 'Internal server error',
      message: process.env.NODE_ENV === 'development' ? error.message : undefined,
    },
  };
});

Multiple Instances

You can run multiple dashboard instances with different configurations:

const prodAdapter = new ExpressAdapter();
prodAdapter.setBasePath('/admin/prod-queues');

createDashboard({
  queues: [new BullMQAdapter(prodQueue)],
  serverAdapter: prodAdapter,
  options: {
    uiConfig: { title: 'Production Queues' },
  },
});

const devAdapter = new ExpressAdapter();
devAdapter.setBasePath('/admin/dev-queues');

createDashboard({
  queues: [new BullMQAdapter(devQueue)],
  serverAdapter: devAdapter,
  options: {
    uiConfig: { title: 'Development Queues' },
  },
});

app.use('/admin/prod-queues', prodAdapter.getRouter());
app.use('/admin/dev-queues', devAdapter.getRouter());

Dependencies

  • express: ^4.21.2
  • ejs: ^3.1.10
  • @aios-medical/bullmq-dashboard-api: ^1.0.0
  • @aios-medical/bullmq-dashboard-ui: ^1.0.0

License

MIT

版本与发布记录

@aios-medical/bullmq-dashboard-express 共发布 3 个版本,首次发布于 2026/05/28;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.2latest2026/06/065 个月前
1.0.12026/06/065 个月前
1.0.02026/05/285 个月前

关于 @aios-medical/bullmq-dashboard-express 的常见问题

@aios-medical/bullmq-dashboard-express 是什么?

Express.js server adapter for the aios bullmq dashboard.

如何安装 @aios-medical/bullmq-dashboard-express?

在项目目录运行 npm install @aios-medical/bullmq-dashboard-express,或使用 pnpm add / yarn add / bun add。

@aios-medical/bullmq-dashboard-express 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aios-medical/bullmq-dashboard-express 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aios-medical/bullmq-dashboard-express 可以商用吗?

@aios-medical/bullmq-dashboard-express 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aios-medical/bullmq-dashboard-express 的下载量有多少?

根据 npm 官方下载统计,@aios-medical/bullmq-dashboard-express 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,896 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aios-medical/bullmq-dashboard-express 还在维护吗?

最新版本 1.0.2 发布于 2026/06/06(5 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。