πŸ“Bull Board Queue

Queue management panel.

Imports

import { queuePool } from 'niro-health'
import { getBullBoardQueues } from 'niro-health';

Implementing the queue panel

In this example, I am using Express.

main.ts
import { NestFactory } from '@nestjs/core';
import { getBullBoardQueues } from 'niro-health';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const bullBoardUserName = "USERNAME";
  const bullBoardPassword = "PASSWORD";

  passport.use(
    new BasicStrategy((username, password, done) => {
      if (username === bullBoardUserName && password === bullBoardPassword) {
        done(null, true);
      } else {
        done(null, false);
      }
    }),
  );
  
  const serverAdapter = new ExpressAdapter();
  serverAdapter.setBasePath('/admin/queues');
  
  const queues = getBullBoardQueues();
  
  createBullBoard({
    queues,
    serverAdapter,
  });
  
  app.use(
    '/admin/queues',
    passport.authenticate('basic', {
      session: false,
    }),
    serverAdapter.getRouter(),
  );
  
  await app.listen(3000);
}
bootstrap();

Creating our Job

I will use the example from the user module.

VocΓͺ pode ver o cΓ³digo oficial no Github.

The folder structure will look like this:

  • jobs

  • configs

    • email

      • accountActivate.ts

  • constants

    • email

      • accountActivateProcess.ts

      • emailNameJob.ts

  • types

    • email

      • accountActivate.ts

  • email.ts

Injecting the queues into the main module.

Injecting the queues into the users module.

Injetando as filas no controller do modulo de usuarios

Constants

Constant
Description

queuePool

This is a pool of queues that will be used by BullBoard.

getBullBoardQueues

This is a function that will be used by BullBoard to get the queues.

Last updated