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

cqrs-proxy

v0.0.9

Published

The Nest.js CQRS bus helping to communicate with remote workers.

Readme

Nest.js CQRS Proxy Bus

npm version

The package provides a CQRS Proxy Bus for Nest.js applications. It allows you to create a proxy bus that can be used to send commands to different handlers by @nestjs/microservices workflow and handle them by workers.

Useful Links

Installation

You can install it using yarn or any other package manager:

yarn add cqrs-proxy

Don't forget to setup peer dependencies:

yarn add @nestjs/cqrs @nestjs/schematics @nestjs/common @nestjs/core @nestjs/microservices rxjs uuid class-transformer

Usage

Importing the Module

To use the CQRS Proxy Bus, you need to import the CqrsProxyClientModule into your Nest.js module as client:

import { CqrsProxyClientModule } from 'cqrs-proxy'

@Module({
  imports: [
    CqrsProxyClientModule.register({
      clientToken: 'AMQP_CLIENT', // The name of the microservice
      useSyncMode: false, // Set to true if you want to use synchronous mode for DEBUG
    }),
  ],
})
export class MyModule {}

Async mode

You can also use the async mode to register the module:

import { CqrsProxyClientModule } from 'cqrs-proxy'

@Module({
  imports: [
    CqrsProxyClientModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        clientToken: config.get('clientToken', 'AMQP_CLIENT'),
        useSyncMode: config.get('useWorker', true),
      }),
    }),
  ],
})
export class MyModule {}

Sending Commands

You can send commands using the ProxyBus service. Here's an example of how to send a command:

import { Injectable } from '@nestjs/common'
import { ICommand } from '@nestjs/cqrs'

import { ProxyBus } from 'cqrs-proxy'

class MyCommand implements ICommand {
  constructor(public readonly data: string) {}
}

@Injectable()
export class MyService {
  constructor(private readonly proxyBus: ProxyBus) {}

  public async run(): Promise<void> {
    const command = new MyCommand('Hello, World!')
    await this.proxyBus.execute(command) // returns metadata with id
  }
}

Handling Commands

All magic happens in the worker. You need to import CqrsProxyWorkerModule into your root module and create a handler for your command and register it in the worker module using default CqrsModule and command handler matching to MyCommand from example above:

import { Module } from '@nestjs/common'
import { CqrsModule } from '@nestjs/cqrs'
import { CqrsProxyWorkerModule } from 'cqrs-proxy'

import { MyCommandHandler } from './my-command.handler'
import { MyCommand } from './my-command.command'
import { MyService } from './my.service'

@CommandHandler(MyCommand)
export class MyCommandHandler implements ICommandHandler<MyCommand> {
  public async execute(command: MyCommand): Promise<void> {
    console.log('Handling command:', command.data) // Handling command: Hello, World!
  }
}

@Module({
  imports: [CqrsModule, CqrsProxyWorkerModule.forRoot()],
  providers: [MyService, MyCommandHandler],
})
export class MyWorkerModule {}

Contributing

I welcome contributions! Follow these steps to contribute:

  1. Setup environment
    1. Fork the repository.
    2. Clone your forked repository.
    3. Install dependencies by running yarn install.
  2. Making Changes
    1. Create a new branch for your changes.
    2. Make your changes and commit them.
    3. Push your changes to your forked repository.
  3. Submitting a Pull Request
    1. Go to the original repository on GitHub and click the "New pull request" button.
    2. Select your branch and submit the pull request.
    3. Wait for the review and address any feedback.

You are the star of this project! 🌟