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

@nhtio/adonis-mqtt-event-bus

v1.20250319.0

Published

A cross-process event bus for AdonisJS based on MQTT

Downloads

2

Readme

Adonis MQTT Event Bus

A cross-process event bus for AdonisJS based on MQTT

Features

  • Provides centralized, event-driven architecture across containerized applications.
  • Clean integration with AdonisJS IoC, leveraging dependency injection.
  • Efficient, lightweight inter-container/event-driven communication.

Getting Started

Installation

Install the package using your preferred package manager:

npm install @nhtio/adonis-mqtt-event-bus

Run the Adonis configuration command to set up the package:

node ace configure @nhtio/adonis-mqtt-event-bus

Configuration

The configuration file for the MQTT Event Bus will be located at config/meb.ts. You can customize the following options:

export default {
  host: 'mqtt://127.0.0.1:1883', // The MQTT broker URL
  baseTopic: 'adonis',           // The base topic for all events
  // you can add more options here
};

Make sure your MQTT broker is running and accessible at the specified host.

Accessing the Event Bus

You can access the event bus through one of the following methods:

1. As an Importable Service

import meb from '@nhtio/adonis-mqtt-event-bus/services/main';

// Example usage
meb.emit('my:event', { key: 'value' });
meb.on('my:event', (payload) => {
  console.log(payload);
});

2. As an Attribute of the Application

import { default as app } from "@adonisjs/core/services/app";

// Access the event bus
app.meb.emit('my:event', { key: 'value' });

3. Using Container Services

import { default as app } from "@adonisjs/core/services/app";

// Resolve the event bus from the IoC container
const meb = await app.container.make('meb');
meb.emit('my:event', { key: 'value' });

Adding Typescript Definitions for Events

You can add support for more events by augmenting the EventCallbackSignatures interface:

declare module "@nhtio/adonis-mqtt-event-bus" {
  interface EventCallbackSignatures {
    // your additional definitions here
  }
}

Instance Methods

| Method | Description | Documentation | | -------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | addListener(eventName, listener) | Adds the listener function to the end of the listeners array for the event. | Documentation | | emit(eventName[, ...args]) | Syncronously emits the event to the MQTT broker | Documentation | | eventNames() | Returns an array listing the events for which the emitter has registered listeners. | Documentation | | getMaxListeners() | Returns the current max listener value for the EventEmitter | Documentation | | listenerCount(eventName[, listener]) | Returns the number of listeners listening for the event. | Documentation | | listeners(eventName) | Returns a copy of the array of listeners for the event. | Documentation | | off(eventName, listener) | Removes the specified listener from the listener array for the event | Documentation | | on(eventName, listener) | Adds the listener function to the end of the listeners array for the event. | Documentation | | once(eventName, listener) | Adds a one-time listener function for the event. | Documentation | | prependListener(eventName, listener) | Adds the listener function to the beginning of the listeners array for the event. | Documentation | | prependOnceListener(eventName, listener) | Adds a one-time listener function for the event | Documentation | | removeAllListeners([eventName]) | Removes all listeners, or those of the specified eventName. | Documentation | | removeListener(eventName, listener) | Removes the specified listener from the listener array for the event | Documentation | | setMaxListeners(n) | Set the maximum number of listeners for a specific event before a warning is triggered | Documentation | | rawListeners(eventName) | Returns a copy of the array of listeners for the event, including any wrappers | Documentation | | boot | Runs tasks for when the Adonis bindings have booted | | | start | Run tasks for when the Adonis application has started | | | ready | Run tasks for when the Adonis application is in a ready state | | | shutdown | Run tasks for when the Adonis application is shutting down | | | clearDeadLetterQueue | Clears the dead-letter queue | | | publish(eventName, options, [, ...args]) | Asyncronously emits the event to the MQTT Broker. Uses options from mqttjs#publish | mqttjs#publish | | addWildcardListener(eventName, listener) | Adds the listener function to the end of the listeners array for the event. | Documentation | | offWildcard(eventName, listener) | Removes the specified listener from the listener array for the event | Documentation | | onWildcard(eventName, listener) | Adds the listener function to the end of the listeners array for the event. | Documentation | | onceWildcard(eventName, listener) | Adds a one-time listener function for the event. | Documentation | | prependWildcardListener(eventName, listener) | Adds the listener function to the beginning of the listeners array for the event. | Documentation | | prependOnceWildcardListener(eventName, listener) | Adds a one-time listener function for the event | Documentation | | removeAllWildcardListeners([eventName]) | Removes all listeners, or those of the specified eventName. | Documentation | | removeWildcardListener(eventName, listener) | Removes the specified listener from the listener array for the event | Documentation |

Instance Properties

| Property | Description | | ----------------- | ------------------------------------------------------------------------------------ | | connected | Boolean for if connected to the MQTT Broker | | state | An object which indicates the Adonis Application Lifecycle progress | | deadLetterQueue | A list of events for which there has not been a listener active since the last check |


Adonis MQTT Event Bus is a commercial work product released under the MIT License and is provided as-is with no warranty or guarantee of support.

Copyright © 2025-present New Horizon Technology LTD