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

@itavy/mq-router

v1.0.0

Published

MQ Router

Downloads

20

Readme

MQ-Router

Instalation

npm install @itavy/mq-router

API

Classes

Objects

Typedefs

MQRouter

Class MQRouter

Kind: global class

new MQRouter(mqURI, [connector], mqMessage, mqKnownMessages, mqDefaultMessageVersion, name, [queue], [topic], [exchange], [errorCollector], [defaultHandler], [defaultTTL])

| Param | Type | Default | Description | | --- | --- | --- | --- | | mqURI | String | | uri for connecting to mq bus | | [connector] | String | RABBIT_MQ | connector type to use | | mqMessage | Object | | message builder | | mqKnownMessages | Array.<Object> | | list of known message versions | | mqDefaultMessageVersion | Object | | default version of message to use | | name | String | | router identifier | | [queue] | String | '' | own queue on which the router will listen | | [topic] | String | '' | own topic on which the router will listen | | [exchange] | String | '' | exchange to bind the topic | | [errorCollector] | function | | function to be called when unknown messages are received | | [defaultHandler] | function | | function which resolves to a promise to be called when it receives specific messages | | [defaultTTL] | Number | 5 | default ttl in seconds for messages or requests sent |

mqRouter.sendMessage(message, version, queue, exchange, [options]) ⇒ Promise

Send message over mq

Kind: instance method of MQRouter
Returns: Promise - resolves when the message is accepted by the broker
Access: public

| Param | Type | Default | Description | | --- | --- | --- | --- | | message | Buffer | | message to be sent | | version | Object | | version of message to be sent | | queue | String | | queue or topic where to send the message | | exchange | String | | exchange to be used along with queue/topic to send the message, empty string means the default exchange will be used | | [options] | MQPublishOptions | {} | options for sending message |

mqRouter.sendRequest(message, queue, exchange, [options], version) ⇒ Promise

Send request over mq

Kind: instance method of MQRouter
Returns: Promise - resolves when the message is received
Access: public

| Param | Type | Default | Description | | --- | --- | --- | --- | | message | Buffer | | message to be sent | | queue | String | | queue or topic where to send the message | | exchange | String | | exchange to be used along with queue/topic to send the message, empty string means the default exchange will be used | | [options] | MQPublishOptions | {} | options for sending request | | version | Object | | version of message to be sent |

mqRouter.subscribe(handler, [queue], [topic], [exchange], [options]) ⇒ Promise

Subscribe to queue

Kind: instance method of MQRouter
Returns: Promise - resolves on success subscribe
Access: public

| Param | Type | Default | Description | | --- | --- | --- | --- | | handler | Promise | | Promise to be called when it is received a message | | [queue] | String | '' | queue where to subscribe or '' for autogenerated queue | | [topic] | String | '' | topic to bind the queue or '' for none | | [exchange] | String | '' | exchange to be used for queue and topic or '' for default | | [options] | Object | {} | subscribe options |

mqRouter.close() ⇒ Promise

Close stops checks for expired messages and close connection

Kind: instance method of MQRouter
Returns: Promise - resolves when connection is closed
Access: public

RequestsRoutingTable

MQRequestsRoutingTable class

Kind: global class

new RequestsRoutingTable(name, [checkInterval])

| Param | Type | Default | Description | | --- | --- | --- | --- | | name | String | | router name | | [checkInterval] | Number | 200 | check interval in ms to see if requests have passed their ttl |

requestsRoutingTable.register(serializedMessage, id, options) ⇒ Promise

Register a check for a request

Kind: instance method of RequestsRoutingTable
Returns: Promise - resolves with promise that will be resolved upon receiving message
Access: public

| Param | Type | Description | | --- | --- | --- | | serializedMessage | Buffer | message to be sent | | id | String | message id | | options | Object | message options |

requestsRoutingTable.callById(id, [message], [error]) ⇒ Boolean

Resolve a request

Kind: instance method of RequestsRoutingTable
Returns: Boolean - true if listener exists
Throws:

  • IError if listener does not exists

Access: public

| Param | Type | Default | Description | | --- | --- | --- | --- | | id | String | | message id | | [message] | Buffer | | response message | | [error] | Object | | error to be sent to handler |

requestsRoutingTable.setMessagesTimeoutListener(emitter) ⇒ undefined

Setter for event emitter

Kind: instance method of RequestsRoutingTable
Access: public

| Param | Type | Description | | --- | --- | --- | | emitter | EventEmitter | event emitter |

requestsRoutingTable.close() ⇒ undefined

Stops checks for expired messages

Kind: instance method of RequestsRoutingTable
Access: public

itavy/mq-router : object

MQRouter module

Kind: global namespace

MQPublishOptions : Object

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | ttl | Number | ttl in seconds for the message |

TODO

  • more examples and better documentation
  • more e2e testing
  • refactor tests for nodejs 6

LICENSE

MIT