Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/svtslv/nestjs-bullmq
BullMQ module for NestJS
https://github.com/svtslv/nestjs-bullmq
bull bullmq nest nestjs queue redis
Last synced: 7 days ago
JSON representation
BullMQ module for NestJS
- Host: GitHub
- URL: https://github.com/svtslv/nestjs-bullmq
- Owner: svtslv
- License: mit
- Created: 2020-04-11T05:37:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T01:17:05.000Z (5 months ago)
- Last Synced: 2024-09-19T13:50:50.502Z (about 2 months ago)
- Topics: bull, bullmq, nest, nestjs, queue, redis
- Language: TypeScript
- Homepage:
- Size: 408 KB
- Stars: 22
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS BullMQ
## Table of Contents
- [Description](#description)
- [Installation](#installation)
- [Examples](#examples)
- [License](#license)## Description
Integrates BullMQ with Nest## Installation
```bash
npm install nestjs-bullmq bullmq
```You can also use the interactive CLI
```sh
npx nestjs-modules
```## Examples
### BullMQModule.forRoot(options, connection?)
```ts
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?)
```ts
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?)
```ts
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