Giter VIP home page Giter VIP logo

bull-board-nestjs's Introduction

@bull-board @bull-board/nestjs

NestJS for bull-board.

npm version npm downloads licence

Overview UI

Installation

Install both @bull-board/api and this module.

$ npm install --save @bull-board/nestjs @bull-board/api

Install the Express or Fastify adapter depending on what you use in NestJS (default is Express)

$ npm install --save @bull-board/express
//or 
$ npm install --save @bull-board/fastify

Register the root module

Once the installation is completed, we can import the BullBoardModule into your rootmodule e.g. AppModule.

import { Module } from '@nestjs/common';
import { BullBoardModule } from "@bull-board/nestjs";
import { ExpressAdapter } from "@bull-board/express";

@Module({
  imports: [
    BullModule.forRoot({
      // your bull module config here.
    }),

    BullBoardModule.forRoot({
      route: '/queues',
      adapter: ExpressAdapter // Or FastifyAdapter from `@bull-board/fastify`
    }),
  ],
})
export class AppModule {
}

The forRoot() method registers the bull-board instance and allows you to pass several options to both the instance and module. The following options are available.

  • route the base route for the bull-board instance adapter.
  • adapter The routing adapter to be used, either the Express Adapter or Fastify Adapter provided by bull-board.
  • boardOptions options as provided by the bull-board package, such as uiBasePath and uiConfig
  • middleware optional middleware for the express adapter (e.g. basic authentication)

Register your queues

To register a new queue, you need to register BullBoardModule.forFeature in the same module as where your queues are registered.

import { Module } from '@nestjs/common';
import { BullBoardModule } from "@bull-board/nestjs";
import { BullModule } from "@nestjs/bullmq";

@Module({
  imports: [
    BullModule.registerQueue(
      {
        name: 'my_awesome_queue'
      }
    ),
    
    BullBoardModule.forFeature({
      name: 'my_awesome_queue',
      adapter: BullMQAdapter, //or use BullAdapter if you're using bull instead of bullMQ
    }),
  ],
})
export class FeatureModule {}

The forFeature method registers the given queues to the bull-board instance. The following options are available.

  • name the queue name to register
  • adapter either BullAdapter or BullMQAdapter depending on which package you use.
  • options queue adapter options as found in the bull-board package, such as readOnlyMode, description etc.

Using the bull-board instance in your controllers and/or services.

The created bull-board instance is available via the @InjectBullBoard() decorator. For example in a controller:

import { Controller, Get } from "@nestjs/common";
import { BullBoardInstance, InjectBullBoard } from "@bull-board/nestjs";

@Controller('my-feature')
export class FeatureController {

  constructor(
    @InjectBullBoard() private readonly boardInstance: BullBoardInstance
  ) {
  }
  
  //controller methods
}

Usage examples

  1. Simple NestJS setup

For more info visit the main README

bull-board-nestjs's People

Contributors

dimbslmh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.