@taphealth/kafka 1.2.41 → 1.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,68 +1,68 @@
1
- # Kafka Helper Library
2
-
3
- ## Overview
4
-
5
- This repository provides a Kafka helper library designed for seamless integration of Kafka messaging in tap-health-backend. It abstracts complexities of the KafkaJS library, offering simplified interfaces for both producing and consuming messages.
6
-
7
- ## Key Features
8
-
9
- - **KafkaClient**: Manages Kafka connections and administrative operations such as topic creation.
10
- - **KafkaProducer**: Facilitates easy production of messages to Kafka topics.
11
- - **KafkaConsumer**: Simplifies consumption of messages from Kafka topics.
12
-
13
- ## Usage
14
-
15
- ### Installation
16
-
17
- Install the library using pnpm:
18
-
19
- ```bash
20
- pnpm install @taphealth/kafka
21
- ```
22
-
23
- ### Connecting to Kafka
24
-
25
- Initialize a KafkaClient instance to connect to Kafka brokers:
26
-
27
- ```typescript
28
- import { KafkaClient } from "@taphealth/kafka";
29
-
30
- const kafkaClient = new KafkaClient();
31
- await kafkaClient.connect(["localhost:9092"]);
32
- ```
33
-
34
- ### Producing Messages
35
-
36
- Use KafkaProducer to send messages to Kafka topics:
37
-
38
- ```typescript
39
- import { KafkaProducer } from "@taphealth/kafka";
40
- import { Topics } from "@taphealth/kafka";
41
- import { YourEventInterface } from "./your-event-interface";
42
-
43
- const producer = new KafkaProducer() < YourEventInterface > kafkaClient.client;
44
- await producer.send({
45
- // Your message payload
46
- });
47
- ```
48
-
49
- ### Consuming Messages
50
-
51
- Extend KafkaConsumer to implement message handling logic:
52
-
53
- ```typescript
54
- import { KafkaConsumer } from "@taphealth/kafka";
55
- import { Topics } from "@taphealth/kafka";
56
- import { YourEventInterface } from "./your-event-interface";
57
-
58
- export class YourEventConsumer extends KafkaConsumer<YourEventInterface> {
59
- topic = Topics.YourTopic;
60
-
61
- async onMessage(data: YourEventInterface["data"], message: any) {
62
- // business logic
63
- }
64
- }
65
-
66
- const consumer = new YourEventConsumer(kafkaClient.client);
67
- await consumer.consume();
68
- ```
1
+ # Kafka Helper Library
2
+
3
+ ## Overview
4
+
5
+ This repository provides a Kafka helper library designed for seamless integration of Kafka messaging in tap-health-backend. It abstracts complexities of the KafkaJS library, offering simplified interfaces for both producing and consuming messages.
6
+
7
+ ## Key Features
8
+
9
+ - **KafkaClient**: Manages Kafka connections and administrative operations such as topic creation.
10
+ - **KafkaProducer**: Facilitates easy production of messages to Kafka topics.
11
+ - **KafkaConsumer**: Simplifies consumption of messages from Kafka topics.
12
+
13
+ ## Usage
14
+
15
+ ### Installation
16
+
17
+ Install the library using pnpm:
18
+
19
+ ```bash
20
+ pnpm install @taphealth/kafka
21
+ ```
22
+
23
+ ### Connecting to Kafka
24
+
25
+ Initialize a KafkaClient instance to connect to Kafka brokers:
26
+
27
+ ```typescript
28
+ import { KafkaClient } from "@taphealth/kafka";
29
+
30
+ const kafkaClient = new KafkaClient();
31
+ await kafkaClient.connect(["localhost:9092"]);
32
+ ```
33
+
34
+ ### Producing Messages
35
+
36
+ Use KafkaProducer to send messages to Kafka topics:
37
+
38
+ ```typescript
39
+ import { KafkaProducer } from "@taphealth/kafka";
40
+ import { Topics } from "@taphealth/kafka";
41
+ import { YourEventInterface } from "./your-event-interface";
42
+
43
+ const producer = new KafkaProducer() < YourEventInterface > kafkaClient.client;
44
+ await producer.send({
45
+ // Your message payload
46
+ });
47
+ ```
48
+
49
+ ### Consuming Messages
50
+
51
+ Extend KafkaConsumer to implement message handling logic:
52
+
53
+ ```typescript
54
+ import { KafkaConsumer } from "@taphealth/kafka";
55
+ import { Topics } from "@taphealth/kafka";
56
+ import { YourEventInterface } from "./your-event-interface";
57
+
58
+ export class YourEventConsumer extends KafkaConsumer<YourEventInterface> {
59
+ topic = Topics.YourTopic;
60
+
61
+ async onMessage(data: YourEventInterface["data"], message: any) {
62
+ // business logic
63
+ }
64
+ }
65
+
66
+ const consumer = new YourEventConsumer(kafkaClient.client);
67
+ await consumer.consume();
68
+ ```
@@ -0,0 +1,8 @@
1
+ import { Topics } from "../topics";
2
+ export interface DietCreatedEvent {
3
+ topic: Topics.DietCreated;
4
+ data: {
5
+ userId: string;
6
+ date: string;
7
+ };
8
+ }
@@ -0,0 +1,8 @@
1
+ import { Topics } from "../topics";
2
+ export interface DietGenerateEvent {
3
+ topic: Topics.DietGenerate;
4
+ data: {
5
+ userId: string;
6
+ date: string;
7
+ };
8
+ }
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * from "./events/dtx-created";
14
14
  export * from "./events/expiration-complete";
15
15
  export * from "./events/refund-initiate";
16
16
  export * from "./events/refund-processed";
17
- export * from "./events/diet-cron";
18
- export * from "./events/scheduler";
17
+ export * from "./events/diet-created";
18
+ export * from "./events/diet-generate";
19
19
  export * from "./events/dtx-created";
20
20
  export * from "./events/profile-updated";
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ __exportStar(require("./events/dtx-created"), exports);
30
30
  __exportStar(require("./events/expiration-complete"), exports);
31
31
  __exportStar(require("./events/refund-initiate"), exports);
32
32
  __exportStar(require("./events/refund-processed"), exports);
33
- __exportStar(require("./events/diet-cron"), exports);
34
- __exportStar(require("./events/scheduler"), exports);
33
+ __exportStar(require("./events/diet-created"), exports);
34
+ __exportStar(require("./events/diet-generate"), exports);
35
35
  __exportStar(require("./events/dtx-created"), exports);
36
36
  __exportStar(require("./events/profile-updated"), exports);
package/dist/topics.d.ts CHANGED
@@ -4,7 +4,8 @@ export declare enum Topics {
4
4
  AppointmentComplete = "appointment-complete",
5
5
  AppointmentTimer = "appointment-timer",
6
6
  DtxCreated = "dtx-created",
7
- DietCron = "diet-cron",
7
+ DietCreated = "diet-created",
8
+ DietGenerate = "diet-generate",
8
9
  OfflineAppointmentCreated = "offline-appointment-created",
9
10
  OfflineAppointmentUpdated = "offline-appointment-updated",
10
11
  PaymentCaptured = "payment-captured",
@@ -12,6 +13,5 @@ export declare enum Topics {
12
13
  ExpirationComplete = "expiration-complete",
13
14
  RefundInitiate = "refund-initiate",
14
15
  RefundProcessed = "refund-processed",
15
- ProfileUpdated = "profile-updated",
16
- Scheduler = "scheduler"
16
+ ProfileUpdated = "profile-updated"
17
17
  }
package/dist/topics.js CHANGED
@@ -8,7 +8,8 @@ var Topics;
8
8
  Topics["AppointmentComplete"] = "appointment-complete";
9
9
  Topics["AppointmentTimer"] = "appointment-timer";
10
10
  Topics["DtxCreated"] = "dtx-created";
11
- Topics["DietCron"] = "diet-cron";
11
+ Topics["DietCreated"] = "diet-created";
12
+ Topics["DietGenerate"] = "diet-generate";
12
13
  Topics["OfflineAppointmentCreated"] = "offline-appointment-created";
13
14
  Topics["OfflineAppointmentUpdated"] = "offline-appointment-updated";
14
15
  Topics["PaymentCaptured"] = "payment-captured";
@@ -17,5 +18,4 @@ var Topics;
17
18
  Topics["RefundInitiate"] = "refund-initiate";
18
19
  Topics["RefundProcessed"] = "refund-processed";
19
20
  Topics["ProfileUpdated"] = "profile-updated";
20
- Topics["Scheduler"] = "scheduler";
21
21
  })(Topics || (exports.Topics = Topics = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taphealth/kafka",
3
- "version": "1.2.41",
3
+ "version": "1.2.43",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,8 +0,0 @@
1
- import { Topics } from "../topics";
2
- export interface DietCronEvent {
3
- topic: Topics.DietCron;
4
- data: {
5
- topic: Topics.DietCron;
6
- userId: string;
7
- };
8
- }
@@ -1,8 +0,0 @@
1
- import { Topics } from "../topics";
2
- export interface SchedulerEvent {
3
- topic: Topics.Scheduler;
4
- name: string;
5
- cron: string;
6
- delay: string;
7
- data: any;
8
- }
File without changes
File without changes