npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hazeljs/queue

v1.0.6

Published

Redis-backed job queue module for HazelJS framework using BullMQ

Readme

@hazeljs/queue

Background jobs that don't get lost.

BullMQ + Redis. Add jobs from controllers, process with @Queue. Delay, retry, priority, backoff. Works with CronModule for distributed cron. Agent tasks, emails, exports — queue it and forget it.

npm version npm downloads License: Apache-2.0

Features

  • Redis-backed - Uses BullMQ for reliable, distributed job queues
  • BullMQ re-exports - Worker, Job, JobsOptions, WorkerOptions, and BullMQQueue (BullMQ's Queue class; avoids clashing with the @Queue decorator)
  • QueueService - Injectable service for adding jobs from controllers and services
  • @Queue decorator - Mark methods as job processors for Worker setup
  • Job options - Delay, priority, attempts, backoff, timeout
  • HazelJS integration - Works with CronModule for distributed cron jobs

Installation

npm install @hazeljs/queue ioredis

Quick Start

1. Import QueueModule

import { HazelModule } from '@hazeljs/core';
import { QueueModule } from '@hazeljs/queue';

@HazelModule({
  imports: [
    QueueModule.forRoot({
      connection: {
        host: process.env.REDIS_HOST || 'localhost',
        port: parseInt(process.env.REDIS_PORT || '6379', 10),
      },
    }),
  ],
})
export class AppModule {}

2. Add Jobs

import { Injectable } from '@hazeljs/core';
import { QueueService } from '@hazeljs/queue';

@Injectable()
export class EmailService {
  constructor(private queue: QueueService) {}

  async sendWelcomeEmail(userId: string, email: string) {
    await this.queue.add('emails', 'welcome', { userId, email });
  }

  async sendDelayedReminder(userId: string, delayMs: number) {
    await this.queue.addDelayed('emails', 'reminder', { userId }, delayMs);
  }

  async processWithRetry(data: { orderId: string }) {
    await this.queue.addWithRetry('orders', 'process', data, {
      attempts: 3,
      backoff: { type: 'exponential', delay: 1000 },
    });
  }
}

3. Process Jobs with BullMQ Worker

Create a worker process (or run alongside your app) to process jobs:

import { Worker } from '@hazeljs/queue';

const worker = new Worker(
  'emails',
  async (job) => {
    if (job.name === 'welcome') {
      await sendWelcomeEmail(job.data.userId, job.data.email);
    } else if (job.name === 'reminder') {
      await sendReminder(job.data.userId);
    }
  },
  {
    connection: {
      host: process.env.REDIS_HOST || 'localhost',
      port: parseInt(process.env.REDIS_PORT || '6379', 10),
    },
  }
);

worker.on('completed', (job) => console.log(`Job ${job.id} completed`));
worker.on('failed', (job, err) => console.error(`Job ${job?.id} failed:`, err));

4. Using @Queue Decorator for Processor Metadata

The @Queue decorator marks methods as job processors. Use QueueModule.getProcessorMetadata() to get processor info for Worker setup:

import { Injectable } from '@hazeljs/core';
import { Queue } from '@hazeljs/queue';

@Injectable()
export class EmailProcessor {
  @Queue('emails')
  async handleWelcome(job: { data: { userId: string; email: string } }) {
    await this.sendWelcome(job.data.userId, job.data.email);
  }

  @Queue('emails')
  async handleReminder(job: { data: { userId: string } }) {
    await this.sendReminder(job.data.userId);
  }

  private async sendWelcome(userId: string, email: string) {
    // ...
  }
  private async sendReminder(userId: string) {
    // ...
  }
}

Integration with Cron

For distributed cron jobs, enqueue work from cron handlers instead of doing it inline:

import { Injectable } from '@hazeljs/core';
import { Cron, CronExpression } from '@hazeljs/cron';
import { QueueService } from '@hazeljs/queue';

@Injectable()
export class TaskService {
  constructor(private queue: QueueService) {}

  @Cron({
    name: 'daily-cleanup',
    cronTime: CronExpression.EVERY_DAY_AT_MIDNIGHT,
  })
  async triggerCleanup() {
    // Enqueue for distributed processing instead of running inline
    await this.queue.add('maintenance', 'daily-cleanup', {});
  }
}

API Reference

QueueService

  • add(queueName, jobName, data?, options?) - Add a job
  • addDelayed(queueName, jobName, data, delayMs) - Add a delayed job
  • addWithRetry(queueName, jobName, data, options) - Add with retry config
  • getQueue(name) - Get BullMQ Queue instance
  • close() - Close all queue connections

Job Options (JobsOptions)

  • delay - Delay before processing (ms)
  • priority - Higher = processed first
  • attempts - Retry count
  • backoff - { type: 'fixed' | 'exponential', delay: number }
  • timeout - Job timeout (ms)

See Also