@growsari/event-gateway-client
v1.0.3
Published
Client library for interacting with Growsari Event Gateway
Keywords
Readme
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 --saveUsage
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 } }]);