# redis-msg-broker

> A pub/sub msg_broker with redis.

Latest version **1.0.7** (published 2022-07-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install redis-msg-broker
pnpm add redis-msg-broker
yarn add redis-msg-broker
bun add redis-msg-broker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-07-30 |
| First published | 2022-07-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Abolfazl Miadian |
| Maintainers | miadian |
| Keywords | redis, message-broker |

## Links

- npm: https://www.npmjs.com/package/redis-msg-broker
- npm.io page: https://npm.io/package/redis-msg-broker

## Dependencies (1)

- [redis](https://npm.io/package/redis.md) ^4.2.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2022-07-30
- 1.0.6 — 2022-07-28
- 1.0.5 — 2022-07-28
- 1.0.4 — 2022-07-28
- 1.0.3 — 2022-07-28
- 1.0.2 — 2022-07-28
- 1.0.0 — 2022-07-28

## README

In the name of ALLAH

This is  a simple module that connecto to redis and handle publish and subscribe tasks.

How to use:

just import to your project and create an object like this:

	const MsgBroker = require('redis-msg-broker').MsgBroker;
	const msg_broker = new MsgBroker(); // have two optional arguments, first get a json object, secound get dev-status .
		
OR

	const MsgBroker = require('redis-msg-broker').MsgBroker;
	const msg_broker = new MsgBroker({host: "redis-server",port: 6379,db: 16},true);
		
OR

	const MsgBroker = require('redis-msg-broker').MsgBroker;
	const msg_broker = new MsgBroker({url: 'redis://redis:6379'}),true);				



MsgBroker have two async methods, publish and subscribe.

publish method get an argument {type: String, msg: json} like this example: 

	msg_broker.publish({type: "news", msg: {subject:"test subject", txt:"this just an example" } }).then((val)=>{console.log(val);}).catch((err)=>{console.log(err)});


subscribe method get an argument {type: String} and every time recive a message with wanted type, emit that msg as json obj, like this example: 


	msg_broker.subscribe({type: "news"}).then((val)=>{console.log(val);}).catch((err)=>{console.log(err)});
	
then for handling subscribed "news" we can do like this:

	msg_broker.on('news', function (msg) {
		console.log("we recive this msg object ",msg); // msg is an json obj
	});

---
_Source: https://npm.io/package/redis-msg-broker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
