From 5aae9b85389a98fce0893ddc3552c93270f1a6cd Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Wed, 7 Jan 2026 17:20:00 +0200 Subject: [PATCH 01/11] feat: destruct userdata object --- config/default.json | 8 ++++---- src/common/interfaces.ts | 4 ++-- src/process/models/processManager.ts | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config/default.json b/config/default.json index fd35968..72c1831 100644 --- a/config/default.json +++ b/config/default.json @@ -12,7 +12,7 @@ } }, "server": { - "port": "8080", + "port": "8000", "request": { "payload": { "limit": "1mb" @@ -26,7 +26,7 @@ } }, "kafka": { - "brokers": "kafka:9092", + "brokers": "localhost:9092", "enableSslAuth": false, "sslPaths": { "ca": "", @@ -41,7 +41,7 @@ "input": ["topic"] }, "elastic": { - "node": "http://elasticsearch:9200", + "node": "https://vector-elasticsearch-vector-dev.apps.j1lk3njp.eastus.aroapp.io", "auth": { "username": "elastic", "password": "changeme" @@ -53,7 +53,7 @@ }, "application": { "userDataService": { - "endpoint": "http://user-data-service:8080", + "endpoint": "http://localhost/mirage", "queryParams": { "extraDetails": true }, diff --git a/src/common/interfaces.ts b/src/common/interfaces.ts index 4655d63..4199ed2 100644 --- a/src/common/interfaces.ts +++ b/src/common/interfaces.ts @@ -8,9 +8,9 @@ export interface IConfig { export interface EnrichResponse { user?: { - [key: string]: string | UserDataServiceResponse; + // [key: string]: string | UserDataServiceResponse[string]; name: string; - }; + } & Partial; query: { text?: string; language: string; diff --git a/src/process/models/processManager.ts b/src/process/models/processManager.ts index 1681ede..3590c21 100644 --- a/src/process/models/processManager.ts +++ b/src/process/models/processManager.ts @@ -60,8 +60,13 @@ export class ProcessManager { enrichedResponse.user = { name: feedbackResponse.geocodingResponse.userId as string, - ...fetchedUserData, }; + + if (feedbackResponse.geocodingResponse.userId !== undefined && fetchedUserData[feedbackResponse.geocodingResponse.userId] !== null) { + const userData = fetchedUserData[feedbackResponse.geocodingResponse.userId]; + enrichedResponse.user = { ...enrichedResponse.user, ...userData }; + } + enrichedResponse.result = { rank: chosenResult, // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition From 4967cc3eadb0c4a4893e19ab0a032f5ee7e2c3f2 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 13:06:08 +0200 Subject: [PATCH 02/11] fix: default.json config --- config/default.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/default.json b/config/default.json index 72c1831..fd35968 100644 --- a/config/default.json +++ b/config/default.json @@ -12,7 +12,7 @@ } }, "server": { - "port": "8000", + "port": "8080", "request": { "payload": { "limit": "1mb" @@ -26,7 +26,7 @@ } }, "kafka": { - "brokers": "localhost:9092", + "brokers": "kafka:9092", "enableSslAuth": false, "sslPaths": { "ca": "", @@ -41,7 +41,7 @@ "input": ["topic"] }, "elastic": { - "node": "https://vector-elasticsearch-vector-dev.apps.j1lk3njp.eastus.aroapp.io", + "node": "http://elasticsearch:9200", "auth": { "username": "elastic", "password": "changeme" @@ -53,7 +53,7 @@ }, "application": { "userDataService": { - "endpoint": "http://localhost/mirage", + "endpoint": "http://user-data-service:8080", "queryParams": { "extraDetails": true }, From ffca78cc58291a97e2250c5a9560d4349889e057 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 13:19:35 +0200 Subject: [PATCH 03/11] feat: used different zookeeper image --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 12bbd4f..bbf9d5c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -60,7 +60,7 @@ jobs: --health-retries 30 zookeeper: - image: bitnami/zookeeper:3.8.0 + image: zookeeper:3.8.4 ports: - 2181:2181 env: From c22d1a43a3e0f0841d8f0e38b2d5b42b901b3cd9 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 13:22:42 +0200 Subject: [PATCH 04/11] feat: used different kafka image --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index bbf9d5c..3e9650e 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -67,7 +67,7 @@ jobs: ALLOW_ANONYMOUS_LOGIN: yes kafka: - image: bitnami/kafka:3.8.0 + image: apache/kafka:3.8.0 ports: - 9092:9092 env: From 9ca01c5a22a1a2efd6fe93d85e938c927ba7b762 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 13:30:20 +0200 Subject: [PATCH 05/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 3e9650e..87d243d 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -63,8 +63,6 @@ jobs: image: zookeeper:3.8.4 ports: - 2181:2181 - env: - ALLOW_ANONYMOUS_LOGIN: yes kafka: image: apache/kafka:3.8.0 @@ -72,14 +70,15 @@ jobs: - 9092:9092 env: KAFKA_BROKER_ID: 1 - KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 - ALLOW_PLAINTEXT_LISTENER: yes + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 + KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 options: >- --health-cmd "kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1" --health-interval 10s - --health-timeout 5s - --health-retries 5 + --health-timeout 10s + --health-retries 10 strategy: matrix: From 08df4810e50e9d68d7256cff780caea212dda583 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 13:32:56 +0200 Subject: [PATCH 06/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 87d243d..e55a8c5 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -59,21 +59,22 @@ jobs: --health-timeout 10s --health-retries 30 - zookeeper: - image: zookeeper:3.8.4 - ports: - - 2181:2181 - kafka: image: apache/kafka:3.8.0 ports: - 9092:9092 env: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_NODE_ID: 1 + KAFKA_PROCESS_ROLES: broker,controller + KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 - KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT + KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 + KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 options: >- --health-cmd "kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1" --health-interval 10s From 29f4113b53c0c139379af2358a97e8964183a791 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 16:06:20 +0200 Subject: [PATCH 07/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index e55a8c5..32a99e6 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -75,12 +75,12 @@ jobs: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 - options: >- - --health-cmd "kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1" - --health-interval 10s - --health-timeout 10s - --health-retries 10 - + options: >- + --health-cmd "bash -lc 'kafka-broker-api-versions.sh --bootstrap-server 127.0.0.1:9092 >/dev/null 2>&1'" + --health-interval 10s + --health-timeout 10s + --health-retries 30 + strategy: matrix: node: [18.x, 20.x] From a922bf721c6070495f7bb09b3e6938635d92ebdb Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Thu, 8 Jan 2026 16:28:43 +0200 Subject: [PATCH 08/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 32a99e6..12a9708 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -97,11 +97,11 @@ jobs: - name: Install Node.js dependencies run: npm ci - - name: Install Docker + - name: Check Docker run: | - apt-get update - apt-get install -y docker.io - + docker --version + docker ps + - name: Wait for Kafka run: | until docker exec $(docker ps -qf "name=kafka") kafka-topics.sh --list --bootstrap-server localhost:9092; do From aa0708b8e3061deb14a985c99c490559ac6430ba Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Sun, 11 Jan 2026 10:38:07 +0200 Subject: [PATCH 09/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 12a9708..ecb6ae1 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -97,17 +97,15 @@ jobs: - name: Install Node.js dependencies run: npm ci - - name: Check Docker - run: | - docker --version - docker ps - - name: Wait for Kafka + shell: bash run: | - until docker exec $(docker ps -qf "name=kafka") kafka-topics.sh --list --bootstrap-server localhost:9092; do - echo "Waiting for Kafka to be ready..."; - sleep 5; + for i in {1..60}; do + (echo > /dev/tcp/kafka/9092) >/dev/null 2>&1 && echo "Kafka is up" && exit 0 + echo "Waiting for Kafka..." + sleep 2 done + exit 1 - name: Create Kafka topic1 run: | From 5d8b1401037cdbaeb63c8aed7c4805e908e592d0 Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Sun, 11 Jan 2026 10:53:14 +0200 Subject: [PATCH 10/11] fix: changes to workflow due to depricated images --- .github/workflows/pull_request.yaml | 39 +++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index ecb6ae1..907028b 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -107,15 +107,38 @@ jobs: done exit 1 - - name: Create Kafka topic1 - run: | - docker exec $(docker ps -qf "name=kafka") \ - kafka-topics.sh --create --topic topic1-test --bootstrap-server localhost:9092 - - - name: Create Kafka topic2 + - name: Create Kafka topics + env: + KAFKA_BROKERS: kafka:9092 run: | - docker exec $(docker ps -qf "name=kafka") \ - kafka-topics.sh --create --topic topic2-test --bootstrap-server localhost:9092 + node - <<'NODE' + const { Kafka } = require('kafkajs'); + + (async () => { + const brokers = (process.env.KAFKA_BROKERS || 'kafka:9092').split(','); + const kafka = new Kafka({ clientId: 'ci-topic-init', brokers }); + + const admin = kafka.admin(); + await admin.connect(); + + const topics = ['topic1-test', 'topic2-test']; + + // Create topics only if missing (idempotent-ish) + // KafkaJS createTopics will return false if topics already exist. + const created = await admin.createTopics({ + topics: topics.map(t => ({ topic: t, numPartitions: 1, replicationFactor: 1 })), + waitForLeaders: true, + timeout: 30000, + }); + + console.log(`createTopics result: ${created ? 'created' : 'already existed'}`); + + await admin.disconnect(); + })().catch(err => { + console.error(err); + process.exit(1); + }); + NODE - name: Wait for Elasticsearch run: | From 7c79dbe64ff4e24a082d1c27634623f1b305fcef Mon Sep 17 00:00:00 2001 From: NatalieShaked Date: Sun, 11 Jan 2026 11:02:55 +0200 Subject: [PATCH 11/11] fix: removed comment --- src/common/interfaces.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/interfaces.ts b/src/common/interfaces.ts index 4199ed2..b2e3d91 100644 --- a/src/common/interfaces.ts +++ b/src/common/interfaces.ts @@ -8,7 +8,6 @@ export interface IConfig { export interface EnrichResponse { user?: { - // [key: string]: string | UserDataServiceResponse[string]; name: string; } & Partial; query: {