1.0.3 • Published 5 years ago

@growsari/event-gateway-client v1.0.3

Weekly downloads
4
License
ISC
Repository
-
Last release
5 years ago

Event Gateway Client

Client library for interacting with Growsari Event Gateway

Installation

Install the package using the below command:

$ npm i @growsari/event-gateway-client --save

Usage

Create EventGatway Client

Create a client by passing in clientId (for now till the service implements authentication)

let client = new EventGatewayClient('ms-loc');

Subsribe to a topic

It accepts topic name and notification url (to get the notifications)

client.subscribeToTopic(topicName, notificationUrl);

Publish message to a topic

It accepts topic name and list of messages. Each message contains event name and the payload.

client.publishMessage(topicName, [ message,..}]);

Examples:

let client = new EventGatewayClient('ms-loc');

// Subscribe to a Topic - orders
client.subscribeToTopic('orders', 'http://127.0.0.1/ms-loc/test-event-push');

// Publish Event Message to a Topic - orders
client.publishMessage('orders', [{ event: 'ORDER_CREATED', payload: { "order_id": 10, "price": 10.0 } }]);