@taphealth/kafka 1.2.35 → 1.2.37
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 +68 -68
- package/dist/events/diet-cron.d.ts +1 -1
- package/dist/events/profile-updated.d.ts +2 -0
- package/dist/events/scheduler.d.ts +1 -0
- package/dist/types/profile.d.ts +52 -16
- package/package.json +1 -1
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
|
+
```
|
package/dist/types/profile.d.ts
CHANGED
|
@@ -1,19 +1,55 @@
|
|
|
1
1
|
export interface settings {
|
|
2
|
-
|
|
2
|
+
sleepTime: string;
|
|
3
|
+
hasBreakfast: boolean;
|
|
4
|
+
breakfastMealSize: string;
|
|
5
|
+
hasBeverageInBreakfast: boolean;
|
|
6
|
+
hasLunch: boolean;
|
|
7
|
+
hasVegetables: boolean;
|
|
8
|
+
vegetableIntake: string;
|
|
9
|
+
hasPulsesInLunch: boolean;
|
|
10
|
+
lunchPulseIntake: string;
|
|
11
|
+
hasMeatInLunch: boolean;
|
|
12
|
+
lunchMeatIntake: string;
|
|
13
|
+
hasRotiInLunch: boolean;
|
|
14
|
+
lunchRotiIntake: string;
|
|
15
|
+
medicalConditions: string[];
|
|
16
|
+
recentSurgery: boolean;
|
|
17
|
+
diet: DietPreferences;
|
|
18
|
+
diabetes: DiabetesPreferences;
|
|
3
19
|
}
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
export interface DiabetesPreferences {
|
|
21
|
+
programReason: string[];
|
|
22
|
+
motivation: string[];
|
|
23
|
+
goal: string[];
|
|
24
|
+
barriers: string[];
|
|
25
|
+
cravings: string[];
|
|
26
|
+
diagnosisDate: string;
|
|
27
|
+
sugarFastingLevel: string;
|
|
28
|
+
sugarFastingCheckedDate: string;
|
|
29
|
+
sugarPostMealLevel: string;
|
|
30
|
+
sugarPostMealCheckedDate: string;
|
|
31
|
+
hba1cLevel: string;
|
|
32
|
+
history: string[];
|
|
33
|
+
diabetesInFamily: boolean;
|
|
34
|
+
dietPreference: string;
|
|
35
|
+
cuisinePreferences: string[];
|
|
36
|
+
pulses: string[];
|
|
37
|
+
grains: string[];
|
|
38
|
+
vegetables: string[];
|
|
39
|
+
nonVegPreferences: string[];
|
|
40
|
+
nonVegDays: string[];
|
|
41
|
+
medications: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface DietPreferences {
|
|
44
|
+
dietReason: string;
|
|
45
|
+
activityLevel: string;
|
|
46
|
+
allergies: string[];
|
|
47
|
+
dietPreference: string;
|
|
48
|
+
cuisinePreferences: string[];
|
|
49
|
+
pulses: string[];
|
|
50
|
+
grains: string[];
|
|
51
|
+
vegetables: string[];
|
|
52
|
+
nonVegPreferences: string[];
|
|
53
|
+
nonVegDays: string[];
|
|
54
|
+
medications: string[];
|
|
19
55
|
}
|