felixmosh / bull-board

🎯 Queue background jobs inspector
MIT License
2.36k stars 366 forks source link

I'm using a koa.js based development framework egg.js, but it doesn't seem to be supported at the moment. #753

Closed ahuijiLearning closed 5 months ago

ahuijiLearning commented 6 months ago

app.js

'use strict';

const { createBullBoard } = require('@bull-board/api');
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
const { KoaAdapter } = require('@bull-board/koa');
const { Queue: QueueMQ } = require('bullmq');

class AppBootHook {
  constructor(app) {
    this.app = app;
  }
  async serverDidReady() {
    const connection = { };

    const queues = [ new BullMQAdapter(new QueueMQ('test', { connection })) ];

    const serverAdapter = new KoaAdapter();
    serverAdapter.setBasePath('/bull-board');

    createBullBoard({ queues, serverAdapter });

    await this.app.use(serverAdapter.registerPlugin());
  }
}

module.exports = AppBootHook;

I am now trying to use the KoaAdapter, and the access interface returns this error.

{
  "error": "Internal server error",
  "message": "Can't find index.ejs from ",
  "details": "AssertionError [ERR_ASSERTION]: Can't find index.ejs from \n    at ViewManager.resolve (/XXX/egg-view/lib/view_manager.js:74:5)\n    at async [contextView#render] (/XXX/egg-view/lib/context_view.js:52:22)\n    at async /XXX/@bull-board/koa/dist/KoaAdapter.js:99:17\n    at async /XXX/koa-mount/index.js:52:26\n    at async /XXX/@bull-board/koa/dist/KoaAdapter.js:78:17\n    at async /XXX/koa-mount/index.js:58:5\n    at async /XXX/egg-development/app/middleware/egg_loader_trace.js:9:50"
}

What should I do if I want to use it again in my egg.js project.

felixmosh commented 6 months ago

Did you installed @bull-bard/ui?

ahuijiLearning commented 6 months ago

I looked at the module already there, and tried to set uiBasePath without success, same error message.

"dependencies": {
    "@bull-board/api": "5.18.3"
 },

1716543245013

ahuijiLearning commented 6 months ago

Minimum reproducible code:

  1. You can initialize an egg.js project like here. https://www.eggjs.org/intro/quickstart
  2. After running, add app.js file in the root directory of the project, the file content is my above code (need to use your redis configuration)
  3. Install the package required for this file, and then run again to access the corresponding link
felixmosh commented 6 months ago

Can you make a repo with these reproduction steps?

ahuijiLearning commented 6 months ago

I don't fully understand what you mean, whether it's like this:

https://github.com/ahuijiLearning/bull-board-test

felixmosh commented 6 months ago

Thanx, I'll review it ASAP

felixmosh commented 5 months ago

I debugged your example, looks like egg.js, overrides (or not using at all KoaAdapter's view config, which uses koa-view). Not sure why.

You can supply your own config, check my PR, https://github.com/ahuijiLearning/bull-board-test/pull/1 Closing this as it not related to this lib

ahuijiLearning commented 5 months ago

Thank, It work!