nestjs-bullmq
v0.1.0
Published
Nest - modern, fast, powerful node.js web framework (@bullmq)
Downloads
36
Maintainers
Readme
NestJS BullMQ
Table of Contents
Description
Integrates BullMQ with Nest
Installation
npm install nestjs-bullmq bullmq
You can also use the interactive CLI
npx nestjs-modules
Examples
BullMQModule.forRoot(options, connection?)
import { Module } from '@nestjs/common';
import { BullMQModule } from 'nestjs-bullmq';
import { AppController } from './app.controller';
@Module({
imports: [
BullMQModule.forRoot({
name: 'QueueName',
config: {
// url: 'redis://:password@localhost:6379',
connection: { host: 'localhost', port: 6379 },
},
}),
],
controllers: [AppController],
})
export class AppModule {}
BullMQModule.forRootAsync(options, connection?)
import { Module } from '@nestjs/common';
import { BullMQModule } from 'nestjs-bullmq';
import { AppController } from './app.controller';
@Module({
imports: [
BullMQModule.forRootAsync({
name: 'QueueName',
useFactory: () => ({
config: {
// url: 'redis://:password@localhost:6379',
connection: { host: 'localhost', port: 6379 },
},
}),
}),
],
controllers: [AppController],
})
export class AppModule {}
InjectBullMQ(queueName?, connection?)
import { Controller, Get, } from '@nestjs/common';
import { InjectBullMQ, BullMQ } from 'nestjs-bullmq';
@Controller()
export class AppController {
constructor(
@InjectBullMQ('QueueName') private readonly bullMQ: BullMQ,
) {}
@Get()
async getHello() {
this.bullMQ.process(async job => {
console.log('process', job);
})
this.bullMQ.queue.add('myJobName', { foo: 'bar' });
// this.bullMQ.queueEvents.on();
// this.bullMQ.queueScheduler.on();
}
}
License
MIT