From 909cad0ecfcccee3868d2471cc433d316171ffe0 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Tue, 3 Dec 2024 15:24:17 +0530 Subject: [PATCH] fix: convert to registry pattern --- src/v1/destinations/iterable/networkHandler.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/v1/destinations/iterable/networkHandler.js b/src/v1/destinations/iterable/networkHandler.js index bbc30a4fd2..7b10b148bd 100644 --- a/src/v1/destinations/iterable/networkHandler.js +++ b/src/v1/destinations/iterable/networkHandler.js @@ -4,11 +4,16 @@ const { BULK_ENDPOINTS } = require('../../../v0/destinations/iterable/config'); const { CommonStrategy } = require('./commonStrategy'); const { TrackIdentifyStrategy } = require('./trackIdentifyStrategy'); +const strategyRegistry = { + [TrackIdentifyStrategy.name]: new TrackIdentifyStrategy(), + [CommonStrategy.name]: new CommonStrategy(), +}; + const getResponseStrategy = (endpoint) => { if (BULK_ENDPOINTS.some((path) => endpoint.includes(path))) { - return new TrackIdentifyStrategy(); + return strategyRegistry[TrackIdentifyStrategy.name]; } - return new CommonStrategy(); + return strategyRegistry[CommonStrategy.name]; }; const responseHandler = (responseParams) => {