From 8d1a27285f8fcf6292b41d1b238d14e70efcfb2d Mon Sep 17 00:00:00 2001 From: xtrullor73 Date: Sat, 25 May 2024 00:44:47 -0700 Subject: [PATCH] refactor: streamline env var error messages and general cleanup --- src/utils/checkEnvVariables.js | 4 ++-- src/utils/retryAxios.js | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils/checkEnvVariables.js b/src/utils/checkEnvVariables.js index bd8a5be..de5a6d2 100644 --- a/src/utils/checkEnvVariables.js +++ b/src/utils/checkEnvVariables.js @@ -1,5 +1,5 @@ export default function checkEnvVariables() { - if (!process.env.ACOUSTID_API_KEY || !process.env.SPOTIFY_CLIENT_ID || !process.env.SPOTIFY_CLIENT_SECRET) { - throw new Error('Please set up ACOUSTID_API_KEY, SPOTIFY_CLIENT_ID, and SPOTIFY_CLIENT_SECRET in your .env file.'); + if (!process.env.ACOUSTID_API_KEY) { + throw new Error('Please set up ACOUSTID_API_KEY in your .env file.'); } } diff --git a/src/utils/retryAxios.js b/src/utils/retryAxios.js index 304998d..7601959 100644 --- a/src/utils/retryAxios.js +++ b/src/utils/retryAxios.js @@ -5,11 +5,9 @@ const axiosInstance = axios.create(); axiosRetry(axiosInstance, { retries: 3, // The number of times to retry before failing - retryCondition: (error) => - // Retry on a 429 status code or a 5xx status code + retryCondition: (error) => // Retry on a 429 status code or a 5xx status code error.response.status === 429 || error.response.status >= 500, - retryDelay: (retryCount) => retryCount * 2000 // Wait 2 seconds between retries - , + retryDelay: (retryCount) => retryCount * 2000, // Wait 2 seconds between retries }); export default axiosInstance;