@midwayjs/bull-board 4.0.0-alpha.1 → 4.0.0-beta.10
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.
- package/README.md +1 -1
- package/dist/adapter.js +8 -4
- package/dist/board.manager.d.ts +11 -0
- package/dist/board.manager.js +65 -0
- package/dist/board.middleware.d.ts +0 -3
- package/dist/board.middleware.js +6 -29
- package/dist/configuration.d.ts +3 -2
- package/dist/configuration.js +11 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/index.d.ts +0 -1
- package/package.json +10 -8
package/README.md
CHANGED
package/dist/adapter.js
CHANGED
|
@@ -6,10 +6,14 @@ const path_1 = require("path");
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const core_1 = require("@midwayjs/core");
|
|
8
8
|
class MidwayAdapter {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
basePath = '';
|
|
10
|
+
bullBoardQueues;
|
|
11
|
+
// private errorHandler: ((error: Error) => ControllerHandlerReturnType) | undefined;
|
|
12
|
+
statics;
|
|
13
|
+
viewPath;
|
|
14
|
+
entryRoute;
|
|
15
|
+
apiRoutes;
|
|
16
|
+
staticCache = new Map();
|
|
13
17
|
setBasePath(path) {
|
|
14
18
|
this.basePath = path;
|
|
15
19
|
return this;
|
package/dist/board.manager.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { IMidwayContainer, MidwayFrameworkService } from '@midwayjs/core';
|
|
1
2
|
import { createBullBoard } from '@bull-board/api';
|
|
2
3
|
import { BaseAdapter } from '@bull-board/api/dist/src/queueAdapters/base';
|
|
4
|
+
import { MidwayAdapter } from './adapter';
|
|
5
|
+
import { BullBoardOption } from './interface';
|
|
3
6
|
export declare class BullBoardManager {
|
|
4
7
|
private bullBoard;
|
|
8
|
+
protected bullBoardConfig: BullBoardOption;
|
|
9
|
+
protected frameworkService: MidwayFrameworkService;
|
|
10
|
+
protected applicationContext: IMidwayContainer;
|
|
11
|
+
private basePath;
|
|
12
|
+
private serverAdapter;
|
|
13
|
+
protected init(): Promise<void>;
|
|
14
|
+
getBasePath(): string;
|
|
15
|
+
getServerAdapter(): MidwayAdapter;
|
|
5
16
|
setBullBoard(bullBoard: ReturnType<typeof createBullBoard>): void;
|
|
6
17
|
getBullBoardOrigin(): ReturnType<typeof createBullBoard>;
|
|
7
18
|
addQueue(queue: BaseAdapter): void;
|
package/dist/board.manager.js
CHANGED
|
@@ -5,10 +5,57 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.BullBoardManager = void 0;
|
|
10
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const api_1 = require("@bull-board/api");
|
|
15
|
+
const bullAdapter_1 = require("@bull-board/api/bullAdapter");
|
|
16
|
+
const bullMQAdapter_1 = require("@bull-board/api/bullMQAdapter");
|
|
17
|
+
const adapter_1 = require("./adapter");
|
|
11
18
|
let BullBoardManager = class BullBoardManager {
|
|
19
|
+
bullBoard;
|
|
20
|
+
bullBoardConfig;
|
|
21
|
+
frameworkService;
|
|
22
|
+
applicationContext;
|
|
23
|
+
basePath;
|
|
24
|
+
serverAdapter;
|
|
25
|
+
async init() {
|
|
26
|
+
let framework = this.frameworkService.getFramework('bull');
|
|
27
|
+
if (!framework) {
|
|
28
|
+
framework = this.frameworkService.getFramework('bullmq');
|
|
29
|
+
}
|
|
30
|
+
if (!framework) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const queueList = framework.getQueueList();
|
|
34
|
+
const wrapQueues = queueList.map(queue => {
|
|
35
|
+
if (this.applicationContext.hasNamespace('bull')) {
|
|
36
|
+
return new bullAdapter_1.BullAdapter(queue);
|
|
37
|
+
}
|
|
38
|
+
else if (this.applicationContext.hasNamespace('bullmq')) {
|
|
39
|
+
return new bullMQAdapter_1.BullMQAdapter(queue);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.basePath = this.bullBoardConfig.basePath;
|
|
43
|
+
this.serverAdapter = new adapter_1.MidwayAdapter();
|
|
44
|
+
this.bullBoard = (0, api_1.createBullBoard)({
|
|
45
|
+
queues: wrapQueues,
|
|
46
|
+
serverAdapter: this.serverAdapter,
|
|
47
|
+
options: {
|
|
48
|
+
uiConfig: this.bullBoardConfig.uiConfig,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
this.serverAdapter.setBasePath(this.basePath);
|
|
52
|
+
}
|
|
53
|
+
getBasePath() {
|
|
54
|
+
return this.basePath;
|
|
55
|
+
}
|
|
56
|
+
getServerAdapter() {
|
|
57
|
+
return this.serverAdapter;
|
|
58
|
+
}
|
|
12
59
|
setBullBoard(bullBoard) {
|
|
13
60
|
this.bullBoard = bullBoard;
|
|
14
61
|
}
|
|
@@ -29,6 +76,24 @@ let BullBoardManager = class BullBoardManager {
|
|
|
29
76
|
}
|
|
30
77
|
};
|
|
31
78
|
exports.BullBoardManager = BullBoardManager;
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, core_1.Config)('bullBoard'),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], BullBoardManager.prototype, "bullBoardConfig", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, core_1.Inject)(),
|
|
85
|
+
__metadata("design:type", core_1.MidwayFrameworkService)
|
|
86
|
+
], BullBoardManager.prototype, "frameworkService", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, core_1.ApplicationContext)(),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], BullBoardManager.prototype, "applicationContext", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, core_1.Init)(),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", []),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], BullBoardManager.prototype, "init", null);
|
|
32
97
|
exports.BullBoardManager = BullBoardManager = __decorate([
|
|
33
98
|
(0, core_1.Singleton)()
|
|
34
99
|
], BullBoardManager);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
|
|
2
|
-
import * as bull from '@midwayjs/bull';
|
|
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;
|
|
7
5
|
protected bullBoardConfig: BullBoardOption;
|
|
8
6
|
protected bullBoardManager: BullBoardManager;
|
|
9
7
|
private basePath;
|
|
10
8
|
private serverAdapter;
|
|
11
|
-
protected init(): Promise<void>;
|
|
12
9
|
resolve(app: IMidwayApplication): (req: any, res: any, next: NextFunction) => Promise<any>;
|
|
13
10
|
static getName(): string;
|
|
14
11
|
}
|
package/dist/board.middleware.js
CHANGED
|
@@ -12,10 +12,6 @@ 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
|
-
const api_1 = require("@bull-board/api");
|
|
17
|
-
const bullAdapter_1 = require("@bull-board/api/bullAdapter");
|
|
18
|
-
const adapter_1 = require("./adapter");
|
|
19
15
|
const board_manager_1 = require("./board.manager");
|
|
20
16
|
const MIME_MAP = {
|
|
21
17
|
'.html': 'text/html',
|
|
@@ -36,22 +32,13 @@ const MIME_MAP = {
|
|
|
36
32
|
'.otf': 'application/x-font-opentype',
|
|
37
33
|
};
|
|
38
34
|
let BoardMiddleware = class BoardMiddleware {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.serverAdapter = new adapter_1.MidwayAdapter();
|
|
44
|
-
const bullBoard = (0, api_1.createBullBoard)({
|
|
45
|
-
queues: wrapQueues,
|
|
46
|
-
serverAdapter: this.serverAdapter,
|
|
47
|
-
options: {
|
|
48
|
-
uiConfig: this.bullBoardConfig.uiConfig,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
this.serverAdapter.setBasePath(this.basePath);
|
|
52
|
-
this.bullBoardManager.setBullBoard(bullBoard);
|
|
53
|
-
}
|
|
35
|
+
bullBoardConfig;
|
|
36
|
+
bullBoardManager;
|
|
37
|
+
basePath;
|
|
38
|
+
serverAdapter;
|
|
54
39
|
resolve(app) {
|
|
40
|
+
this.basePath = this.bullBoardManager.getBasePath();
|
|
41
|
+
this.serverAdapter = this.bullBoardManager.getServerAdapter();
|
|
55
42
|
if ('express' === app.getNamespace()) {
|
|
56
43
|
return async (req, res, next) => {
|
|
57
44
|
const pathname = req.path;
|
|
@@ -138,10 +125,6 @@ let BoardMiddleware = class BoardMiddleware {
|
|
|
138
125
|
}
|
|
139
126
|
};
|
|
140
127
|
exports.BoardMiddleware = BoardMiddleware;
|
|
141
|
-
__decorate([
|
|
142
|
-
(0, core_1.Inject)(),
|
|
143
|
-
__metadata("design:type", bull.Framework)
|
|
144
|
-
], BoardMiddleware.prototype, "framework", void 0);
|
|
145
128
|
__decorate([
|
|
146
129
|
(0, core_1.Config)('bullBoard'),
|
|
147
130
|
__metadata("design:type", Object)
|
|
@@ -150,12 +133,6 @@ __decorate([
|
|
|
150
133
|
(0, core_1.Inject)(),
|
|
151
134
|
__metadata("design:type", board_manager_1.BullBoardManager)
|
|
152
135
|
], BoardMiddleware.prototype, "bullBoardManager", void 0);
|
|
153
|
-
__decorate([
|
|
154
|
-
(0, core_1.Init)(),
|
|
155
|
-
__metadata("design:type", Function),
|
|
156
|
-
__metadata("design:paramtypes", []),
|
|
157
|
-
__metadata("design:returntype", Promise)
|
|
158
|
-
], BoardMiddleware.prototype, "init", null);
|
|
159
136
|
exports.BoardMiddleware = BoardMiddleware = __decorate([
|
|
160
137
|
(0, core_1.Provide)(),
|
|
161
138
|
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
|
+
onServerReady(container: IMidwayContainer): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -10,11 +10,13 @@ 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");
|
|
15
|
+
const board_manager_1 = require("./board.manager");
|
|
16
16
|
let BullBoardConfiguration = class BullBoardConfiguration {
|
|
17
|
-
|
|
17
|
+
applicationManager;
|
|
18
|
+
configService;
|
|
19
|
+
async onReady(container) {
|
|
18
20
|
const apps = this.applicationManager.getApplications([
|
|
19
21
|
'express',
|
|
20
22
|
'egg',
|
|
@@ -22,10 +24,16 @@ let BullBoardConfiguration = class BullBoardConfiguration {
|
|
|
22
24
|
]);
|
|
23
25
|
if (apps.length) {
|
|
24
26
|
apps.forEach(app => {
|
|
25
|
-
|
|
27
|
+
if (container.hasNamespace('bull') ||
|
|
28
|
+
container.hasNamespace('bullmq')) {
|
|
29
|
+
app.useMiddleware(board_middleware_1.BoardMiddleware);
|
|
30
|
+
}
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
33
|
}
|
|
34
|
+
async onServerReady(container) {
|
|
35
|
+
await container.getAsync(board_manager_1.BullBoardManager);
|
|
36
|
+
}
|
|
29
37
|
};
|
|
30
38
|
exports.BullBoardConfiguration = BullBoardConfiguration;
|
|
31
39
|
__decorate([
|
|
@@ -39,7 +47,6 @@ __decorate([
|
|
|
39
47
|
exports.BullBoardConfiguration = BullBoardConfiguration = __decorate([
|
|
40
48
|
(0, core_1.Configuration)({
|
|
41
49
|
namespace: 'bull-board',
|
|
42
|
-
imports: [bull],
|
|
43
50
|
importConfigs: [
|
|
44
51
|
{
|
|
45
52
|
default: {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,7 @@ export * from './board.middleware';
|
|
|
3
3
|
export * from './board.manager';
|
|
4
4
|
export * from './interface';
|
|
5
5
|
export * as BullBoard from '@bull-board/api';
|
|
6
|
+
export { MidwayAdapter } from './adapter';
|
|
7
|
+
export { BullAdapter } from '@bull-board/api/bullAdapter';
|
|
8
|
+
export { BullMQAdapter } from '@bull-board/api/bullMQAdapter';
|
|
6
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BullBoard = exports.Configuration = void 0;
|
|
17
|
+
exports.BullMQAdapter = exports.BullAdapter = exports.MidwayAdapter = exports.BullBoard = exports.Configuration = void 0;
|
|
18
18
|
var configuration_1 = require("./configuration");
|
|
19
19
|
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.BullBoardConfiguration; } });
|
|
20
20
|
__exportStar(require("./board.middleware"), exports);
|
|
21
21
|
__exportStar(require("./board.manager"), exports);
|
|
22
22
|
__exportStar(require("./interface"), exports);
|
|
23
23
|
exports.BullBoard = require("@bull-board/api");
|
|
24
|
+
var adapter_1 = require("./adapter");
|
|
25
|
+
Object.defineProperty(exports, "MidwayAdapter", { enumerable: true, get: function () { return adapter_1.MidwayAdapter; } });
|
|
26
|
+
var bullAdapter_1 = require("@bull-board/api/bullAdapter");
|
|
27
|
+
Object.defineProperty(exports, "BullAdapter", { enumerable: true, get: function () { return bullAdapter_1.BullAdapter; } });
|
|
28
|
+
var bullMQAdapter_1 = require("@bull-board/api/bullMQAdapter");
|
|
29
|
+
Object.defineProperty(exports, "BullMQAdapter", { enumerable: true, get: function () { return bullMQAdapter_1.BullMQAdapter; } });
|
|
24
30
|
//# sourceMappingURL=index.js.map
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bull-board",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
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/
|
|
28
|
-
"@midwayjs/
|
|
29
|
-
"@midwayjs/
|
|
30
|
-
"@midwayjs/
|
|
28
|
+
"@midwayjs/bull": "^4.0.0-beta.10",
|
|
29
|
+
"@midwayjs/bullmq": "^4.0.0-beta.10",
|
|
30
|
+
"@midwayjs/core": "^4.0.0-beta.10",
|
|
31
|
+
"@midwayjs/express": "^4.0.0-beta.10",
|
|
32
|
+
"@midwayjs/koa": "^4.0.0-beta.10",
|
|
33
|
+
"@midwayjs/mock": "^4.0.0-beta.10"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"@bull-board/api": "5.23.0",
|
|
34
37
|
"@bull-board/ui": "5.23.0",
|
|
35
|
-
"@midwayjs/bull": "^4.0.0-alpha.1",
|
|
36
38
|
"ejs": "3.1.10"
|
|
37
39
|
},
|
|
38
40
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
41
|
+
"node": ">=20"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "1b1856629913703f67304155aaf611ec936a81ac"
|
|
42
44
|
}
|