Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@discordjs/brokers

Package Overview
Dependencies
Maintainers
0
Versions
881
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discordjs/brokers

Powerful set of message brokers

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
710
decreased by-35.86%
Maintainers
0
Weekly downloads
 
Created
Source

discord.js


Discord server npm version npm downloads Build status Code coverage

Vercel Cloudflare Workers

About

@discordjs/brokers is a powerful set of message brokers

Installation

Node.js 20 or newer is required.

npm install @discordjs/brokers
yarn add @discordjs/brokers
pnpm add @discordjs/brokers

Example usage

pub sub

// publisher.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());

await broker.publish('test', 'Hello World!');
await broker.destroy();

// subscriber.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());
broker.on('test', ({ data, ack }) => {
	console.log(data);
	void ack();
});

await broker.subscribe('subscribers', ['test']);

RPC

// caller.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());

console.log(await broker.call('testcall', 'Hello World!'));
await broker.destroy();

// responder.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());
broker.on('testcall', ({ data, ack, reply }) => {
	console.log('responder', data);
	void ack();
	void reply(`Echo: ${data}`);
});

await broker.subscribe('responders', ['testcall']);

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.

Keywords

FAQs

Package last updated on 02 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc