From 5031a5ef83986a62a18fd00afaad8de894d5ee56 Mon Sep 17 00:00:00 2001 From: King-Hin Leung Date: Thu, 10 Aug 2023 12:13:19 +0200 Subject: [PATCH] Update connect.yaml and edit config inside algolia-sample extension --- connect.yaml | 2 ++ .../algolia-example/configurations/config.js | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/connect.yaml b/connect.yaml index 45b2a3b..84d25d3 100644 --- a/connect.yaml +++ b/connect.yaml @@ -18,6 +18,8 @@ deployAs: description: Commercetools client scope - key: CTP_REGION description: Region of Commercetools project + - key: SEARCH_PLATFORM_CONFIG + description: Escaped JSON object including credentails to search platform and other settings - name: incremental-updater applicationType: event endpoint: / diff --git a/full-ingestion/src/extensions/algolia-example/configurations/config.js b/full-ingestion/src/extensions/algolia-example/configurations/config.js index 9712e9b..5c3717a 100644 --- a/full-ingestion/src/extensions/algolia-example/configurations/config.js +++ b/full-ingestion/src/extensions/algolia-example/configurations/config.js @@ -1,5 +1,15 @@ +function loadConfig() { + try { + return JSON.parse(process.env.SEARCH_PLATFORM_CONFIG); + } catch (e) { + throw new Error( + 'Search platform configuration is not provided in the JSON format' + ); + } +} + export const config = { - applicationId: process.env.AGOLIA_APPLICATION_ID, - searchApiKey: process.env.AGOLIA_SEARCH_API_KEY, - index: process.env.AGOLIA_INDEX, + applicationId: loadConfig().applicationId, + searchApiKey: loadConfig().searchApiKey, + index: loadConfig().index, };