fix: only instantiate service one time

This commit is contained in:
Eli Bosley
2024-12-20 09:56:23 -05:00
parent eff6c32ccd
commit b1b93e2783

View File

@@ -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) {