From b1b93e278396a9f28f4ee3911f90bceb8ed39acb Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Fri, 20 Dec 2024 09:56:23 -0500 Subject: [PATCH] fix: only instantiate service one time --- api/src/mothership/utils/create-local-connect-api-key.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/src/mothership/utils/create-local-connect-api-key.ts b/api/src/mothership/utils/create-local-connect-api-key.ts index 41e1267ef..2f771c713 100644 --- a/api/src/mothership/utils/create-local-connect-api-key.ts +++ b/api/src/mothership/utils/create-local-connect-api-key.ts @@ -11,12 +11,11 @@ export const createLocalApiKeyForConnectIfNecessary = async () => { } const { remote } = getters.config(); - const service = new ApiKeyService(); + const apiKeyService = new ApiKeyService(); // If the remote API Key is set and the local key is either not set or not found on disk, create a key - if (remote.apikey && (!remote.localApiKey || !(await service.findByKey(remote.localApiKey)))) { + if (remote.apikey && (!remote.localApiKey || !(await apiKeyService.findByKey(remote.localApiKey)))) { minigraphLogger.debug('Creating local API key for Connect'); // Create local API key - const apiKeyService = new ApiKeyService(); const localApiKey = await apiKeyService.createLocalConnectApiKey(); if (localApiKey?.key) {