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

nestjs-power-queues

v1.0.34

Published

High-performance Redis Streams queue integration for NestJS based on power-queues.

Readme

nestjs-power-queues

power-queues integration for NestJS

📚 Documentation

Full documentation is available here:
👉 https://nestjs-power-queues.docs.ihor.bielchenko.com

📦 Installation

npm install nestjs-power-queues

OR

yarn add nestjs-power-queues

🧪 Basic usage

1. Connection settings are specified in the .env file:

REDIS_QUEUES_HOST=127.0.0.1
REDIS_QUEUES_PORT=6379
REDIS_QUEUES_DATABASE=1
REDIS_QUEUES_PASSWORD=
REDIS_QUEUES_KEY_EXPIRE=300
REDIS_QUEUES_TLS_CA_CRT=
REDIS_QUEUES_TLS_KEY=
REDIS_QUEUES_TLS_CRT=

For information on creating connections to Redis, see nestjs-power-redis

2. Register module with multiple Redis clients

import { QueueModule } from 'nestjs-power-queues';

@Module({
  imports: [
    QueueModule.forRoot([ 'queues' ]),
  ],
})
export class AppModule {}

3. Inject in a service

import { Injectable } from '@nestjs/common';
import { 
	InjectQueue,
	QueueService, 
} from 'nestjs-power-queues';

@Injectable()
export class MyService {
  constructor(
    @InjectQueue('queues') private readonly queueService: QueueService,
  ) {}

  async test() {
    await this.queueService.addTasks('example:job', [ ...payload ]);
  }
}

4. Example of a worker for executing a MySQL insert transaction

import { Injectable } from '@nestjs/common';
import {
  InjectRedis,
  RedisService,
} from 'nestjs-power-redis';
import { 
  QueueService,
  Task, 
} from 'nestjs-power-queues';
import { 
  isArrFilled,
  isObjFilled,
} from 'full-utils';
import { MysqlService } from 'mysql';
import { Logger } from '../logger';

@Injectable()
export class ExampleQueue extends QueueService {
  public readonly logger: Logger = new Logger(ExampleQueue.name);
  public readonly selectStuckCount: number = 256;
  public readonly selectCount: number = 256;
  public readonly retryCount: number = 3;
  public readonly runOnInit: boolean = true;
  public readonly executeSync: boolean = true;
  public readonly removeOnExecuted: boolean = true;

  constructor(
    @InjectRedis('queues') public readonly redisService: RedisService,
    public readonly mysqlService: MysqlService,
  ) {
    super(redisService);
  }

  queueName(): string {
    return 'mysql_create:example:table_name';
  }

  async onBatchReady(queueName: string, tasks: Task[]) {
    const values = tasks
      .filter((task) => isObjFilled(task.payload))
      .map((task) => task.payload);

    if (isArrFilled(values)) {
      const queryRunner = this.mysqlService.connection('database_name').createQueryRunner();

      await queryRunner.connect();
      await queryRunner.startTransaction();
      try {
        await queryRunner
          .manager
          .createQueryBuilder()
          .insert()
          .into('table_name')
          .values(values)
          .execute();
        await queryRunner.commitTransaction();
      }
      catch (err) {
        await queryRunner.rollbackTransaction();
        throw err;
      }
      finally {
        await queryRunner.release();
      }
    }
  }

  async onBatchError(err: any, queueName: string, tasks: Array<[ string, any, number, string, string, number ]>) {
    this.logger.error('Transaction error', queueName, tasks.length, (process.env.NODE_ENV === 'production')
      ? err.message
      : err, tasks.map((task) => task[1]));
  }
}

The runOnInit parameter determines whether queue processing should start immediately after the application starts.

📜 License

MIT - free for commercial and private use.