diff --git a/packages/server/package.json b/packages/server/package.json index c32f01b9fe..6217f27934 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -71,6 +71,8 @@ "@budibase/auth": "^0.9.185-alpha.9", "@budibase/client": "^0.9.185-alpha.9", "@budibase/string-templates": "^0.9.185-alpha.9", + "@bull-board/api": "^3.7.0", + "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -80,7 +82,6 @@ "aws-sdk": "^2.767.0", "bcryptjs": "2.4.3", "bull": "^3.22.4", - "bull-board": "^2.0.1", "chmodr": "1.2.0", "csvtojson": "2.0.10", "dotenv": "8.2.0", @@ -139,7 +140,6 @@ "copyfiles": "^2.4.1", "docker-compose": "^0.23.6", "eslint": "^6.8.0", - "express": "^4.17.1", "jest": "^27.0.5", "nodemon": "^2.0.4", "prettier": "^2.3.1", diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 23e05e5e95..c44b6123aa 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -41,16 +41,8 @@ app.use( ) if (!env.isTest()) { - const bullApp = bullboard.init() - app.use(async (ctx: ExtendableContext, next: () => any) => { - if (ctx.path.startsWith(bullboard.pathPrefix)) { - ctx.status = 200 - ctx.respond = false - bullApp(ctx.req, ctx.res) - } else { - await next() - } - }) + const plugin = bullboard.init() + app.use(plugin) } app.context.eventEmitter = eventEmitter diff --git a/packages/server/src/automations/bullboard.js b/packages/server/src/automations/bullboard.js index 50a177781b..67f3f4ce56 100644 --- a/packages/server/src/automations/bullboard.js +++ b/packages/server/src/automations/bullboard.js @@ -1,6 +1,6 @@ -const { createBullBoard } = require("bull-board") -const { BullAdapter } = require("bull-board/bullAdapter") -const express = require("express") +const { createBullBoard } = require("@bull-board/api") +const { BullAdapter } = require("@bull-board/api/bullAdapter") +const { KoaAdapter } = require("@bull-board/koa") const env = require("../environment") const Queue = env.isTest() ? require("../utilities/queue/inMemoryQueue") @@ -19,7 +19,7 @@ async function cleanup() { await automationQueue.clean(CLEANUP_PERIOD_MS, "completed") } -exports.pathPrefix = "/bulladmin" +const PATH_PREFIX = "/bulladmin" exports.init = () => { // cleanup the events every 5 minutes @@ -30,17 +30,19 @@ exports.init = () => { console.error(`Unable to cleanup automation queue initially - ${err}`) }) } - const expressApp = express() // Set up queues for bull board admin const queues = [automationQueue] const adapters = [] + const serverAdapter = new KoaAdapter() for (let queue of queues) { adapters.push(new BullAdapter(queue)) } - const { router } = createBullBoard(adapters) - - expressApp.use(exports.pathPrefix, router) - return expressApp + createBullBoard({ + queues: adapters, + serverAdapter, + }) + serverAdapter.setBasePath(PATH_PREFIX) + return serverAdapter.registerPlugin() } exports.queue = automationQueue