Closed brkn closed 2 years ago
You can check an existing implementation adapters, method
field can be an array.
https://github.com/felixmosh/bull-board/blob/master/packages/express/src/ExpressAdapter.ts#L55
https://github.com/felixmosh/bull-board/blob/master/packages/fastify/src/FastifyAdapter.ts#L57
method
& route
should be treated as an array of, but they can be single thing, or and array of things.
Tip, you can normalize this kind with [].concat(aThing)
, when aThing
may be a string
or string[]
, will produce [aThing]
in both of the cases.
For example:
const route = "/some/route";
console.log([].concat(route)); // = ["/some/route"];
const routeAsArray = ["/some/route1", "/some/route2"];
console.log([].concat(routeAsArray)); // = ["/some/route1", "/some/route2"];
But setApiRoutes
is only called by createBullBoard
, does createBullBoard
ever pass an array there? Is setApiRoutes
supposed to be public to the adapter's end user?
I'm not sure what is you question, can you explain what are you trying to implement?
Assume the usage should be similar to this:
const serverAdapter = new ExpressAdapter();
const queues = [new BullMQAdapter(queueMQ)];
const { addQueue, removeQueue, setQueues, replaceQueues } = createBullBoard({
queues,
serverAdapter,
});
So, createBullBoard
calls to adapters setApiRoutes
method with the relevant end points, the adapter responsibility is to adapt to specific node framework.
If you pay attention, createBullBoard
is kinda of builder design pattern.
Did you managed to solve it?
No I've stopped working on an adonis adapter, for the reasons I've mentioned here
I will either A. Fork the https://github.com/Rocketseat/adonis-bull/tree/alpha/ to make it work somehow B. Share the Worker definitions via private npm package between 2 server repositories and run the dashboard on fastify.
Do you have any small repo boilerplate that uses adonis, maybe I will able to work on integration of it.
Here is the demo for adonis-bull package, which I'm not happy with at all tbh: https://github.com/brkn/adonis-bull-demo-app
Here is the adapter I've lost hope with: https://github.com/brkn/adonis-bull-board-adapter
Looks like there are too many constrains in adonis, I think that a better solution would use an existing adapters.
I'm trying to understand how to write
public setApiRoutes(bullBoardRoutes: AppControllerRoute[])
for an adopter.Rabbit hole
the type definition for
AppControllerRoute
is like this:From my understanding this
AppControllerRoute
is only referenced atAppRouteDefs
in the api package.But at the
packages/api/src/routes.ts
inappRoutes
object, only placeAppRouteDefs
is referenced, method is never an array, it's always a single methodNamestring
like:put
,get
.Question
Should I assume method is never an array even though it's typedef is
method: HTTPMethod | HTTPMethod[];
? Is this for backwards compatibility?Same question for typedefinition of
route: string | string[]