Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/bull

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/bull

Nest - modern, fast, powerful node.js web framework (@bull)

  • 10.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
283K
decreased by-1.32%
Maintainers
2
Weekly downloads
 
Created

What is @nestjs/bull?

@nestjs/bull is a package for the NestJS framework that provides integration with Bull, a popular library for handling distributed job queues. It allows you to create, manage, and process jobs in a queue, making it useful for background processing, task scheduling, and more.

What are @nestjs/bull's main functionalities?

Creating a Queue

This code demonstrates how to set up a queue named 'my-queue' using the @nestjs/bull package. It configures the connection to a Redis server and registers the queue within a NestJS module.

```typescript
import { BullModule } from '@nestjs/bull';

@Module({
  imports: [
    BullModule.forRoot({
      redis: {
        host: 'localhost',
        port: 6379,
      },
    }),
    BullModule.registerQueue({
      name: 'my-queue',
    }),
  ],
})
export class AppModule {}
```

Adding Jobs to a Queue

This code shows how to add jobs to a queue. The `MyService` class injects the 'my-queue' queue and uses the `addJob` method to add a job with the provided data.

```typescript
import { InjectQueue } from '@nestjs/bull';
import { Queue } from 'bull';
import { Injectable } from '@nestjs/common';

@Injectable()
export class MyService {
  constructor(@InjectQueue('my-queue') private readonly myQueue: Queue) {}

  async addJob(data: any) {
    await this.myQueue.add(data);
  }
}
```

Processing Jobs

This code demonstrates how to process jobs in a queue. The `MyQueueProcessor` class is decorated with `@Processor('my-queue')` to indicate it will handle jobs from 'my-queue'. The `handleJob` method processes each job.

```typescript
import { Processor, Process } from '@nestjs/bull';
import { Job } from 'bull';

@Processor('my-queue')
export class MyQueueProcessor {
  @Process()
  async handleJob(job: Job) {
    console.log('Processing job:', job.data);
    // Add your job processing logic here
  }
}
```

Other packages similar to @nestjs/bull

FAQs

Package last updated on 25 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc