Updating bullboard to use the new koa version (supported).

This commit is contained in:
mike12345567 2021-11-17 16:30:06 +00:00
parent 494e042dd8
commit 32f4a87f95
3 changed files with 15 additions and 21 deletions

View File

@ -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",

View File

@ -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

View File

@ -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