Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Koa error #822

Open
dan335 opened this issue Sep 19, 2024 · 20 comments
Open

Koa error #822

dan335 opened this issue Sep 19, 2024 · 20 comments

Comments

@dan335
Copy link

dan335 commented Sep 19, 2024

I get this error when using with Koa.

Error: ENOENT: no such file or directory, open 'D:\web\ai_ledger\views\index.ejs.html'

I'm guessing it's because I'm using @koa/router instead of koa-router which is not supported anymore.

@felixmosh
Copy link
Owner

Hi @dan335
It looks like it is not related to the router version.
For some reason, this line is not working.
Check the reason for that (maybe you are using bundler for the node part?)
Anyway, you can provide options.uiBasePath by yourself, it shoud get the path to the node_modaules/@bull-board/ui folder.

@dan335
Copy link
Author

dan335 commented Sep 23, 2024

Still can't get this to work. See anything wrong? The output of console.log(uiBasePath) is the correct path.

const serverAdapter = new KoaAdapter();

serverAdapter.setBasePath('/admin/queues');

const uiBasePath = join(__dirname, '../', 'node_modules', '@bull-board', 'ui');

console.log(uiBasePath)

createBullBoard({
  queues: [
    new BullMQAdapter(queueUpdateTransactionCategory),
    new BullMQAdapter(queueTrainModel),
    new BullMQAdapter(queueSyncTransactions),
  ],
  serverAdapter,
  options: { uiBasePath }
});

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

Also tried

const uiBasePath = join(__dirname, '../', 'node_modules', '@bull-board', 'ui', 'package.json');

@felixmosh
Copy link
Owner

This is weird, can you debug it, maybe it is related to the fact that you are using windows.

@felixmosh
Copy link
Owner

Any update?

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

Going to do a bit of necromancy here, but at work we use the Koa library to write our web server and I've been wanting to use the @bull-board/koa middleware, but without luck. I'm getting the same error as he is but I think I'm one step further. I actually get the HTML page but it's not loading the static assets.

I made an attempt to use the library on a clean project and it works right off the bat, so my question is, would there be some kind of issue if I bound a bunch of routers and middlewares and then bound that bullboard plugin at /bullmq for example?

@felixmosh
Copy link
Owner

For sure you can add any middleware before the mount of bull-board (check the auth with koa example)

You should debug the adapter (probably something is interfering with the setup)

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

For sure you can add any middleware before the mount of bull-board (check the auth with koa example)

You should debug the adapter (probably something is interfering with the setup)

Interesting, already started toying around but what do you mean by debugging the adapter. With the actual debugger or you mean there are some kind of debug logs that get dumped somewhere?

@felixmosh
Copy link
Owner

No logs, you can modify the code (print to console paths)
Actually there is only one route that handles static files...check it

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

This seems reasonable no? I replaced some parts of the path but the actual path printed to my terminal is right, it leads me to the right place with the static files.

KoaAdapter {
  basePath: '/ui',
  uiConfig: {
    boardTitle: 'Bull Dashboard',
    favIcon: {
      default: 'static/images/logo.svg',
      alternative: 'static/favicon-32x32.png'
    }
  },
  viewPath: '<path-to-project>/<root-dir>/node_modules/@bull-board/ui/dist',
  statics: {
    route: '/static',
    path: '<path-to-project>/<root-dir>/node_modules/@bull-board/ui/dist/static'
  },
  entryRoute: {
    method: 'get',
    route: [ '/', '/queue/:queueName', '/queue/:queueName/:jobId' ],
  }
}

I'd expect http://localhost:8000/ui to get me the page correctly.

const BASE_PATH = '/ui' as const;
const PATH_TO_UI_ASSETS = path.dirname(require.resolve('@bull-board/ui/package.json'));

export function mountBullMQDashboard(app: Koa, queues: Queue[]) {
	const serverAdapter = new KoaAdapter();

	createBullBoard({
		queues: queues.map((q) => new BullMQAdapter(q)),
		serverAdapter,
		options: { uiConfig: {}, uiBasePath: PATH_TO_UI_ASSETS },
	});

	serverAdapter.setBasePath(BASE_PATH);
	app.use(serverAdapter.registerPlugin());
}

@felixmosh
Copy link
Owner

Did you set the basePath of the adapter (what is the value of the base tag in the returned HTML?)

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

Did you set the basePath of the adapter (what is the value of the base tag in the returned HTML?)

Modified my previous comment with some more details.

And the returned HTML resource is labeled ui, which makes sense.

@felixmosh
Copy link
Owner

What is the path of the 404 request of static flies that fails?

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

What is the path of the 404 request of static flies that fails?

For example: http://localhost:8000/ui/static/js/lib-router.73947a57.js with 404.

Same with all the other css (non-google) and js resources.

@felixmosh
Copy link
Owner

Ur client side paths looks OK
Try to remove the uiBasePath (it should resolve automatically)

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

Ur client side paths looks OK Try to remove the uiBasePath (it should resolve automatically)

Same behaviour, unfortunately.

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

Side question, can we .use from a Router instance from the koa-router package?

@felixmosh
Copy link
Owner

I'll be able debug it with you tomorrow, ping me here?

@tomkcey
Copy link

tomkcey commented Nov 13, 2024

I'll be able debug it with you tomorrow, ping me here?

Alright.

@felixmosh
Copy link
Owner

felixmosh commented Nov 14, 2024

I'm available in Discord, my nick isfelixmosh

@tomkcey
Copy link

tomkcey commented Nov 14, 2024

I'm available in Discord, my nick isfelixmosh

Very helpful, added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants