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

@mavonic/ms-event-manager

v1.0.1

Published

Metaservice event manager

Downloads

482

Readme

Meta Service Event Manager

MS Event Manager is a Fastify plugin that provides an easy way to use RabbitMQ for event bus applications.

Installation

To install the plugin, you need to link it to your project:

  1. Navigate to the ms-event-manager directory and run:
npm link
  1. Navigate to your project directory and run:
npm link ms-event-manager

Usage

First, import the plugin in your project:

import msEventManager from 'ms-event-manager';

Then, register the plugin with Fastify and provide the necessary options:

fastify.register(msEventManager, {
  connectionStrings: 'your-connection-string',
  exchange: 'your-exchange',
  queueName: 'your-queue-name',
  durable: true,
  prefetchCount: 1
});

Replace 'your-connection-string', 'your-exchange', and 'your-queue-name' with your actual RabbitMQ connection string, exchange, and queue name.

Options

The plugin accepts the following options:

  • connectionStrings: The connection string to your RabbitMQ server.
  • exchange: The name of the exchange.
  • queueName: The name of the queue.
  • durable: Whether the queue is durable (i.e., it survives a broker restart).
  • prefetchCount: The maximum number of messages sent over the channel that can be awaiting acknowledgement.

Event Creation Process

Creating a new event involves several steps:

  1. Add the routing key: Add a new routing key for your event in the routingKeys.ts file. The routing key should be a string that uniquely identifies your event.

  2. Create an interface: Create a new interface for your event in the interfaces directory. The interface should define the shape of the data that your event will carry. For example, if your event carries a user ID and a username, your interface might look like this:

export interface MyEvent {
  routingKey: RoutingKeys.USER_LOGIN;
  message: {
    id: number;
    name: string;
  };
}
  1. Export the interface: Add an export for your new interface in the index.ts file in the interfaces directory. This allows the interface to be imported from other parts of your project.

  2. Create a file for the service: Create a new file in the services directory for your service. This file should export a function that handles your event. The function should take an instance of your event interface as a parameter.

Remember to name your files according to the service they correspond to. This helps to keep your code organized and makes it easier to find the code related to a specific service.

After you've completed these steps, your new event will be ready to use!