@midwayjs/bull-board 3.0.1 → 3.6.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013 - Now midwayjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/adapter.d.ts CHANGED
@@ -19,9 +19,6 @@ export declare class MidwayAdapter implements IServerAdapter {
19
19
  getStaticRoutes(): string;
20
20
  renderStatic(filename: any): Promise<any>;
21
21
  renderView(filename: any): Promise<unknown>;
22
- runAPI(route: any, params: any, query: any): Promise<{
23
- status: any;
24
- body: any;
25
- }>;
22
+ runAPI(route: any, query: any): Promise<any>;
26
23
  }
27
24
  //# sourceMappingURL=adapter.d.ts.map
package/dist/adapter.js CHANGED
@@ -50,7 +50,13 @@ class MidwayAdapter {
50
50
  if (route.method !== method.toLowerCase()) {
51
51
  return false;
52
52
  }
53
- return !!core_1.PathToRegexpUtil.match(route.regexpPattern)(url);
53
+ const result = core_1.PathToRegexpUtil.match(route.route, {
54
+ decode: decodeURIComponent,
55
+ })(url);
56
+ if (result) {
57
+ route.params = result.params;
58
+ }
59
+ return !!result;
54
60
  });
55
61
  }
56
62
  getStaticRoutes() {
@@ -62,14 +68,16 @@ class MidwayAdapter {
62
68
  if (this.staticCache.has(filename)) {
63
69
  return this.staticCache.get(filename);
64
70
  }
65
- let content = (0, fs_1.readFileSync)(filename, {
71
+ const content = (0, fs_1.readFileSync)(filename, {
66
72
  encoding: 'utf-8',
67
73
  });
68
74
  this.staticCache.set(filename, content);
69
75
  return content;
70
76
  }
71
77
  async renderView(filename) {
72
- const basePath = this.basePath.endsWith('/') ? this.basePath : `${this.basePath}/`;
78
+ const basePath = this.basePath.endsWith('/')
79
+ ? this.basePath
80
+ : `${this.basePath}/`;
73
81
  if (filename === '/') {
74
82
  filename = 'index.ejs';
75
83
  }
@@ -87,16 +95,13 @@ class MidwayAdapter {
87
95
  });
88
96
  });
89
97
  }
90
- async runAPI(route, params, query) {
98
+ async runAPI(route, query) {
91
99
  const response = await route.handler({
92
100
  queues: this.bullBoardQueues,
93
- params,
101
+ params: route.params,
94
102
  query,
95
103
  });
96
- return {
97
- status: response.status || 200,
98
- body: response.body
99
- };
104
+ return response.body;
100
105
  }
101
106
  }
102
107
  exports.MidwayAdapter = MidwayAdapter;
@@ -1,4 +1,4 @@
1
- import type { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
1
+ import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
2
2
  import * as bull from '@midwayjs/bull';
3
3
  export declare class BoardMiddleware implements IMiddleware<IMidwayContext, NextFunction, unknown> {
4
4
  framework: bull.Framework;
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BoardMiddleware = void 0;
13
- const decorator_1 = require("@midwayjs/decorator");
13
+ const core_1 = require("@midwayjs/core");
14
14
  const path_1 = require("path");
15
15
  const bull = require("@midwayjs/bull");
16
16
  const api_1 = require("@bull-board/api");
@@ -47,7 +47,7 @@ let BoardMiddleware = class BoardMiddleware {
47
47
  this.serverAdapter.setBasePath(this.basePath);
48
48
  }
49
49
  resolve(app) {
50
- if (app.getFrameworkType() === decorator_1.MidwayFrameworkType.WEB_EXPRESS) {
50
+ if (app.getFrameworkType() === core_1.MidwayFrameworkType.WEB_EXPRESS) {
51
51
  return async (req, res, next) => {
52
52
  const pathname = req.path;
53
53
  if (pathname.indexOf(this.basePath) === -1) {
@@ -64,7 +64,7 @@ let BoardMiddleware = class BoardMiddleware {
64
64
  else {
65
65
  const matchRoute = this.serverAdapter.matchApiRoutes(req.method, routePath);
66
66
  if (matchRoute) {
67
- content = await this.serverAdapter.runAPI(matchRoute, req.params, req.query);
67
+ content = await this.serverAdapter.runAPI(matchRoute, req.query);
68
68
  }
69
69
  }
70
70
  const ext = (0, path_1.extname)(pathname);
@@ -99,7 +99,7 @@ let BoardMiddleware = class BoardMiddleware {
99
99
  else {
100
100
  const matchRoute = this.serverAdapter.matchApiRoutes(ctx.method, routePath);
101
101
  if (matchRoute) {
102
- content = await this.serverAdapter.runAPI(matchRoute, ctx.params, ctx.query);
102
+ content = await this.serverAdapter.runAPI(matchRoute, ctx.query);
103
103
  }
104
104
  }
105
105
  const ext = (0, path_1.extname)(pathname);
@@ -123,22 +123,22 @@ let BoardMiddleware = class BoardMiddleware {
123
123
  }
124
124
  };
125
125
  __decorate([
126
- (0, decorator_1.Inject)(),
126
+ (0, core_1.Inject)(),
127
127
  __metadata("design:type", bull.Framework)
128
128
  ], BoardMiddleware.prototype, "framework", void 0);
129
129
  __decorate([
130
- (0, decorator_1.Config)('bullBoard'),
130
+ (0, core_1.Config)('bullBoard'),
131
131
  __metadata("design:type", Object)
132
132
  ], BoardMiddleware.prototype, "bullBoardConfig", void 0);
133
133
  __decorate([
134
- (0, decorator_1.Init)(),
134
+ (0, core_1.Init)(),
135
135
  __metadata("design:type", Function),
136
136
  __metadata("design:paramtypes", []),
137
137
  __metadata("design:returntype", Promise)
138
138
  ], BoardMiddleware.prototype, "init", null);
139
139
  BoardMiddleware = __decorate([
140
- (0, decorator_1.Provide)(),
141
- (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
140
+ (0, core_1.Provide)(),
141
+ (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
142
142
  ], BoardMiddleware);
143
143
  exports.BoardMiddleware = BoardMiddleware;
144
144
  //# sourceMappingURL=board.middleware.js.map
@@ -10,13 +10,16 @@ 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 decorator_1 = require("@midwayjs/decorator");
14
13
  const bull = require("@midwayjs/bull");
15
14
  const core_1 = require("@midwayjs/core");
16
15
  const board_middleware_1 = require("./board.middleware");
17
16
  let BullBoardConfiguration = class BullBoardConfiguration {
18
17
  async onReady() {
19
- const apps = this.applicationManager.getApplications(['express', 'egg', 'koa']);
18
+ const apps = this.applicationManager.getApplications([
19
+ 'express',
20
+ 'egg',
21
+ 'koa',
22
+ ]);
20
23
  if (apps.length) {
21
24
  apps.forEach(app => {
22
25
  app.useMiddleware(board_middleware_1.BoardMiddleware);
@@ -25,15 +28,15 @@ let BullBoardConfiguration = class BullBoardConfiguration {
25
28
  }
26
29
  };
27
30
  __decorate([
28
- (0, decorator_1.Inject)(),
31
+ (0, core_1.Inject)(),
29
32
  __metadata("design:type", core_1.MidwayApplicationManager)
30
33
  ], BullBoardConfiguration.prototype, "applicationManager", void 0);
31
34
  __decorate([
32
- (0, decorator_1.Inject)(),
35
+ (0, core_1.Inject)(),
33
36
  __metadata("design:type", core_1.MidwayConfigService)
34
37
  ], BullBoardConfiguration.prototype, "configService", void 0);
35
38
  BullBoardConfiguration = __decorate([
36
- (0, decorator_1.Configuration)({
39
+ (0, core_1.Configuration)({
37
40
  namespace: 'bull-board',
38
41
  imports: [bull],
39
42
  importConfigs: [
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { QueueAdapterOptions } from '@bull-board/api/dist/typings/app';
2
+ import '@midwayjs/bull';
2
3
  export * from './dist/index';
3
4
 
4
5
  declare module '@midwayjs/core/dist/interface' {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/bull-board",
3
- "version": "3.0.1",
3
+ "version": "3.6.1",
4
4
  "description": "midway component for bull",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -24,19 +24,19 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@midwayjs/core": "^3.4.13",
28
- "@midwayjs/decorator": "^3.4.11",
29
- "@midwayjs/koa": "^3.5.3",
30
- "@midwayjs/express": "^3.5.3",
31
- "@midwayjs/mock": "^3.4.13"
27
+ "@midwayjs/core": "^3.6.0",
28
+ "@midwayjs/express": "^3.6.0",
29
+ "@midwayjs/koa": "^3.6.0",
30
+ "@midwayjs/mock": "^3.6.0"
32
31
  },
33
32
  "dependencies": {
34
- "@bull-board/api": "4.3.1",
35
- "@bull-board/ui": "4.3.1",
36
- "@midwayjs/bull": "^3.0.3",
33
+ "@bull-board/api": "4.4.0",
34
+ "@bull-board/ui": "4.4.0",
35
+ "@midwayjs/bull": "^3.6.1",
37
36
  "ejs": "3.1.8"
38
37
  },
39
38
  "engines": {
40
39
  "node": ">=12"
41
- }
40
+ },
41
+ "gitHead": "7aa8d1d712ff5ae7e3b27eb2e154d3f7ee40889a"
42
42
  }