From 0e04fa653d8e9c148bbba6edf2c2a6859e2a1bc1 Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:10:40 +0000 Subject: [PATCH] prevent crash if elastic envs not set --- desci-server/src/elasticSearchClient.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/desci-server/src/elasticSearchClient.ts b/desci-server/src/elasticSearchClient.ts index 0dbb65f04..966c883a2 100644 --- a/desci-server/src/elasticSearchClient.ts +++ b/desci-server/src/elasticSearchClient.ts @@ -18,11 +18,13 @@ const esAuthConfig = !esNodeUrl?.includes('host.docker.internal') } : {}; -export const elasticClient = new Client({ - node: esNodeUrl, - - ...esAuthConfig, - tls: { - rejectUnauthorized: false, // Temporary - }, -}); +export const elasticClient = + esNodeUrl && esUser && esPw + ? new Client({ + node: esNodeUrl, + ...esAuthConfig, + tls: { + rejectUnauthorized: false, // Temporary + }, + }) + : ({} as any);