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

amqp-helper

v1.0.0

Published

A Node.js helper for AMQP messaging.

Readme

amqp-helper

A Node.js helper for AMQP messaging.

Installation

Still to be published on NPM.

Requirements

The library works by pushing and retrieving messages from the message broker identified by the environment variable MESSAGE_BROKER. MESSAGE_BROKER can be whatever you use to identify the message broker host (IP address or hostname). The optional environment variables RABBITMQ_USER and RABBITMQ_PASS are used to authenticate to the MESSAGE_BROKER. Docker Secrets are supported for storing RABBITMQ_USER and RABBITMQ_PASS;

If you're using docker, it's enough to define the env variables into the docker-compose.yml:

  environment:
    - MESSAGE_BROKER=rabbitmq # in this case rabbitmq is the name of another container
    - RABBITMQ_USER=username
    - RABBITMQ_PASS=password

Usage

The aim of the library is to ease AMQP messaging configuration and execution by:

  • removing the overhead of the AMQP connection configuration;
  • offering easy to use (and remember) functions.

Work Queue

Push to a queue

const mq = require('amqp-helper');

mq.push({
  queue: 'basket.save',
  message: {
    products: [4, 8, 15, 16, 23, 42],
    total: 42
  }
});

Retrieve messages from a queue

const mq = require('amqp-helper');

mq.consume({
  queue: 'basket.save',
  callback: res => {
    console.log(res.json);
  }
});

Publish/Subscribe

In this case the communication is handled by defining an exchange instead of a queue.

Publish a message

const mq = require('amqp-helper');

mq.pub({
  exchange: 'order.billing-changed',
  message: {
    data: userData
  }
});

Consume a message

Multiple consumers can subscribe to an exchange and get the same message

const mq = require('amqp-helper');

mq.sub({
  exchange: 'order.billing-changed',
  callback: res => {
    console.log(res);
  }
});

RPC

Remote Procedure Call pattern can be easily set up by:

Invoking an RPC

const mq = require('amqp-helper');

mq.rpc({
  queue: 'user.get',
  message: {
    user_id: 3
  }
}).then(result => {
  console.log(result);
});

Listening for the RPC message

const mq = require('amqp-helper');

mq.consume({
  queue: 'user.get',
  callback: data => {

    // Invoking RPC callback
    data.channel.sendToQueue(
      data.message.properties.replyTo,
      Buffer.from(JSON.stringify({
        userData: {
          name: 'Douglas'
        }
      })),
      {
        correlationId: data.message.properties.correlationId
      }
    );

  }
});

Todo

  • Enhance documentation
  • Code coverage

Contribution

cp .env.dist .env
docker-compose up -d
./npm install
./npm test