ihub-connect
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

A simple library to connect to ihub and consume the messages.

Example:

import { IhubConnection, IhubEvent } from "ihub-connect";

const accessKey = "your-secret-access-key";

const consume = async () => {
  const conn = await IhubConnection.connectToIhub(accessKey);
  const consumer = await conn.createConsumer("shopify");
  consumer.subscribe([IhubEvent.PRODUCT_ANY]);
  consumer.listen(
    (msg) => {
      // do something with the message
    },
    {
      ack: false, // whether or not to ack msg
    }
  );
};

consume();

You can also create multiple consumers:

const consumer = await conn.createConsumer("shopify");
consumer.subscribe([IhubEvent.PRODUCT_ANY]);

const consumer2 = await conn.createConsumer("shopify2");
consumer2.subscribe([IhubEvent.ORDER_CREATED]);

consumer.listen(
  (msg) => {
    // do something with the message
  },
  {
    ack: false, // whether or not to ack msg
  }
);

consumer2.listen(
  (msg) => {
    // do something with the message
  },
  {
    ack: true, // whether or not to ack msg
  }
);

Readme

Keywords

none

Package Sidebar

Install

npm i ihub-connect

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

59.1 kB

Total Files

27

Last publish

Collaborators

  • thangnt294