From f64f1b3bd9bec4036748b98ff8ac0f0431749f30 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 2 Dec 2021 23:57:13 +0100 Subject: chore: upgrade commitlint and eslint-plugin-unicorn to latest (#2295) - upgrade commitlint and eslint-plugin-unicorn dependencies - update prepare-code script to run lint:fix instead of lint - fix unicorn/no-await-expression-member lint issues - various whitespace formatting fixes due to lint:fix --- .../app/Controllers/Http/RecipeController.js | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/internal-server/app/Controllers/Http/RecipeController.js') diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index 1b0ac7035..7e35e6831 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js @@ -13,8 +13,10 @@ const RECIPES_URL = `${LIVE_FERDI_API}/${API_VERSION}/recipes`; class RecipeController { // List official and custom recipes async list({ response }) { - const officialRecipes = JSON.parse(await (await fetch(RECIPES_URL)).text()); - const customRecipesArray = (await Recipe.all()).rows; + const recipesUrlFetch = await fetch(RECIPES_URL); + const officialRecipes = JSON.parse(await recipesUrlFetch).text(); + const allRecipes = await Recipe.all(); + const customRecipesArray = allRecipes.rows; const customRecipes = customRecipesArray.map(recipe => ({ id: recipe.recipeId, name: recipe.name, @@ -46,7 +48,8 @@ class RecipeController { let results; if (needle === 'ferdi:custom') { - const dbResults = (await Recipe.all()).toJSON(); + const allRecipes = await Recipe.all(); + const dbResults = allRecipes.toJSON(); results = dbResults.map(recipe => ({ id: recipe.recipeId, name: recipe.name, @@ -56,20 +59,18 @@ class RecipeController { let remoteResults = []; // eslint-disable-next-line eqeqeq if (Env.get('CONNECT_WITH_FRANZ') == 'true') { - remoteResults = JSON.parse( - await ( - await fetch( - `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, - ) - ).text(), + const recipesUrlFetch = await fetch( + `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, ); + remoteResults = JSON.parse(await recipesUrlFetch.text()); } debug('remoteResults:', remoteResults); - const localResultsArray = ( - await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch() - ).toJSON(); + const recipeQuery = await Recipe.query() + .where('name', 'LIKE', `%${needle}%`) + .fetch(); + const localResultsArray = recipeQuery.toJSON(); const localResults = localResultsArray.map(recipe => ({ id: recipe.recipeId, name: recipe.name, -- cgit v1.2.3-70-g09d2