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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rabbit-on-memory

v2.3.0

Published

A RabbitMQ in memory implementation. Perfect for testing and for implement DDD without external infrastructure

Downloads

7

Readme

Rabbit on memory

Tests

This is a module to implement a basic RabbitMQ system on memory. It allows you to implement DDD in your NodeJS application without deploying extra infrastructure.

With this module you can create exchanges, queues, bind this queues to his exchanges, publish and consume messages, etc. The allowed exchange types are: direct, topic and fanout.

Documentation

  1. Installation
  2. Singleton v/s multiple instances
  3. Options
  4. Quick examples

Installation

# NPM
npm install --save rabbit-on-memory

# Yarn
yarn add rabbit-on-memory

Singleton vs multiple instances

You can run in singleton mode or multiple instances.

// Singleton mode
import RabbitOnMemory from 'rabbit-on-memory';

// The imported object is a singleton instance. It allows you to call directly the methods:
RabbitOnMemory.setConfig(/* ... */);
RabbitOnMemory.publish(/* ... */);
RabbitOnMemory.subscribe(/* ... */);

// But if you want a new instance, you can do it:
const eventBus = RabbitOnMemory.init()
eventBus.setConfig(/* ... */);
eventBus.publish(/* ... */);
eventBus.subscribe(/* ... */);

Options

You can personalize some behaviours for this module using the method setConfig().

import RabbitOnMemory from 'rabbit-on-memory'

// To run the subscribers methods in sync mode
RabbitOnMemory.setConfig({
    syncMode: true // default: false
})

// To propagate exceptions from subscribers and stop the
// execution of the rest of them (only in sync mode)
RabbitOnMemory.setConfig({
    propagateExceptionsOnSyncMode: true // default: false
})

// To activate the debug mode
RabbitOnMemory.setConfig({
    debug: true // default: false
})

Quick examples

Creating a queue and bind to a route on an exchange

import RabbitOnMemory from 'rabbit-on-memory'

const exchange = 'exchange_name'
const exchangeType = 'direct'
const bindRoute = 'core.user.1.event.user.created'
const queue = 'send_email_on_created_user'
const callback = async (msg) => {}

RabbitOnMemory.subscribe(exchange, exchangeType, queue, bindRoute, callback)

/* This will create the exchange if not exists and will
 * create the queue binded to the exchange with the provided
 * bindRoute
*/

Publish message to a route and exchange

import RabbitOnMemory from 'rabbit-on-memory'

const exchange = 'exchange_name'
const route = 'core.user.1.event.user.created'
const msg = {
  content: userData
}

await RabbitOnMemory.publish(exchange, route, content)

/*
 * This will publish that content on the queue of that exchange
 * If this exchange not exists, it will throw an error
 */

Disclaimer

View LICENSE file for the software contained in this image.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.