@midwayjs/bull-board 3.19.3 → 3.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
2
- import * as bull from '@midwayjs/bull';
1
+ import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction, IMidwayContainer, MidwayFrameworkService } from '@midwayjs/core';
3
2
  import { BullBoardOption } from './interface';
4
3
  import { BullBoardManager } from './board.manager';
5
4
  export declare class BoardMiddleware implements IMiddleware<IMidwayContext, NextFunction, unknown> {
6
- protected framework: bull.Framework;
5
+ protected frameworkService: MidwayFrameworkService;
7
6
  protected bullBoardConfig: BullBoardOption;
8
7
  protected bullBoardManager: BullBoardManager;
8
+ protected applicationContext: IMidwayContainer;
9
9
  private basePath;
10
10
  private serverAdapter;
11
11
  protected init(): Promise<void>;
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BoardMiddleware = void 0;
13
13
  const core_1 = require("@midwayjs/core");
14
14
  const path_1 = require("path");
15
- const bull = require("@midwayjs/bull");
16
15
  const api_1 = require("@bull-board/api");
17
16
  const bullAdapter_1 = require("@bull-board/api/bullAdapter");
17
+ const bullMQAdapter_1 = require("@bull-board/api/bullMQAdapter");
18
18
  const adapter_1 = require("./adapter");
19
19
  const board_manager_1 = require("./board.manager");
20
20
  const MIME_MAP = {
@@ -37,8 +37,22 @@ const MIME_MAP = {
37
37
  };
38
38
  let BoardMiddleware = class BoardMiddleware {
39
39
  async init() {
40
- const queueList = this.framework.getQueueList();
41
- const wrapQueues = queueList.map(queue => new bullAdapter_1.BullAdapter(queue));
40
+ let framework = this.frameworkService.getFramework('bull');
41
+ if (!framework) {
42
+ framework = this.frameworkService.getFramework('bullmq');
43
+ }
44
+ if (!framework) {
45
+ return;
46
+ }
47
+ const queueList = framework.getQueueList();
48
+ const wrapQueues = queueList.map(queue => {
49
+ if (this.applicationContext.hasNamespace('bull')) {
50
+ return new bullAdapter_1.BullAdapter(queue);
51
+ }
52
+ else if (this.applicationContext.hasNamespace('bullmq')) {
53
+ return new bullMQAdapter_1.BullMQAdapter(queue);
54
+ }
55
+ });
42
56
  this.basePath = this.bullBoardConfig.basePath;
43
57
  this.serverAdapter = new adapter_1.MidwayAdapter();
44
58
  const bullBoard = (0, api_1.createBullBoard)({
@@ -139,8 +153,8 @@ let BoardMiddleware = class BoardMiddleware {
139
153
  };
140
154
  __decorate([
141
155
  (0, core_1.Inject)(),
142
- __metadata("design:type", bull.Framework)
143
- ], BoardMiddleware.prototype, "framework", void 0);
156
+ __metadata("design:type", core_1.MidwayFrameworkService)
157
+ ], BoardMiddleware.prototype, "frameworkService", void 0);
144
158
  __decorate([
145
159
  (0, core_1.Config)('bullBoard'),
146
160
  __metadata("design:type", Object)
@@ -149,6 +163,10 @@ __decorate([
149
163
  (0, core_1.Inject)(),
150
164
  __metadata("design:type", board_manager_1.BullBoardManager)
151
165
  ], BoardMiddleware.prototype, "bullBoardManager", void 0);
166
+ __decorate([
167
+ (0, core_1.ApplicationContext)(),
168
+ __metadata("design:type", Object)
169
+ ], BoardMiddleware.prototype, "applicationContext", void 0);
152
170
  __decorate([
153
171
  (0, core_1.Init)(),
154
172
  __metadata("design:type", Function),
@@ -1,7 +1,7 @@
1
- import { MidwayApplicationManager, MidwayConfigService } from '@midwayjs/core';
1
+ import { IMidwayContainer, MidwayApplicationManager, MidwayConfigService } from '@midwayjs/core';
2
2
  export declare class BullBoardConfiguration {
3
3
  applicationManager: MidwayApplicationManager;
4
4
  configService: MidwayConfigService;
5
- onReady(): Promise<void>;
5
+ onReady(container: IMidwayContainer): Promise<void>;
6
6
  }
7
7
  //# sourceMappingURL=configuration.d.ts.map
@@ -10,11 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BullBoardConfiguration = void 0;
13
- const bull = require("@midwayjs/bull");
14
13
  const core_1 = require("@midwayjs/core");
15
14
  const board_middleware_1 = require("./board.middleware");
16
15
  let BullBoardConfiguration = class BullBoardConfiguration {
17
- async onReady() {
16
+ async onReady(container) {
18
17
  const apps = this.applicationManager.getApplications([
19
18
  'express',
20
19
  'egg',
@@ -22,7 +21,10 @@ let BullBoardConfiguration = class BullBoardConfiguration {
22
21
  ]);
23
22
  if (apps.length) {
24
23
  apps.forEach(app => {
25
- app.useMiddleware(board_middleware_1.BoardMiddleware);
24
+ if (container.hasNamespace('bull') ||
25
+ container.hasNamespace('bullmq')) {
26
+ app.useMiddleware(board_middleware_1.BoardMiddleware);
27
+ }
26
28
  });
27
29
  }
28
30
  }
@@ -38,7 +40,6 @@ __decorate([
38
40
  BullBoardConfiguration = __decorate([
39
41
  (0, core_1.Configuration)({
40
42
  namespace: 'bull-board',
41
- imports: [bull],
42
43
  importConfigs: [
43
44
  {
44
45
  default: {
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import '@midwayjs/bull';
2
1
  import { BullBoardOption } from './dist/index';
3
2
  export * from './dist/index';
4
3
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/bull-board",
3
- "version": "3.19.3",
3
+ "version": "3.20.0",
4
4
  "description": "midway component for bull",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -13,6 +13,7 @@
13
13
  "midway",
14
14
  "IoC",
15
15
  "bull",
16
+ "bullmq",
16
17
  "bull-ui",
17
18
  "plugin"
18
19
  ],
@@ -24,19 +25,20 @@
24
25
  ],
25
26
  "license": "MIT",
26
27
  "devDependencies": {
27
- "@midwayjs/core": "^3.19.0",
28
- "@midwayjs/express": "^3.19.2",
29
- "@midwayjs/koa": "^3.19.2",
30
- "@midwayjs/mock": "^3.19.2"
28
+ "@midwayjs/bull": "^3.20.0",
29
+ "@midwayjs/bullmq": "^3.20.0",
30
+ "@midwayjs/core": "^3.20.0",
31
+ "@midwayjs/express": "^3.20.0",
32
+ "@midwayjs/koa": "^3.20.0",
33
+ "@midwayjs/mock": "^3.20.0"
31
34
  },
32
35
  "dependencies": {
33
36
  "@bull-board/api": "5.23.0",
34
37
  "@bull-board/ui": "5.23.0",
35
- "@midwayjs/bull": "^3.19.3",
36
38
  "ejs": "3.1.10"
37
39
  },
38
40
  "engines": {
39
41
  "node": ">=12"
40
42
  },
41
- "gitHead": "7c45ca2710e6495d5555419de5b2ab645696c823"
43
+ "gitHead": "5bf838ec6054f6e1e983664b0456a975db795932"
42
44
  }