From e4a7fcbde65f399bc09065890cad750e40d1568e Mon Sep 17 00:00:00 2001 From: kytwb Date: Fri, 31 Dec 2021 13:00:14 +0100 Subject: Remove calls to Franz infra for recipes --- app/Controllers/Http/RecipeController.js | 16 ++-------------- app/Controllers/Http/StaticController.js | 3 +-- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 344548c..066728f 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js @@ -29,7 +29,7 @@ class RecipeController { async list({ response, }) { - const officialRecipes = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes')).text()); + const officialRecipes = fs.readJsonSync(path.join(Helpers.appRoot(), 'recipes', 'all.json')); const customRecipesArray = (await Recipe.all()).rows; const customRecipes = customRecipesArray.map((recipe) => ({ id: recipe.recipeId, @@ -144,21 +144,12 @@ class RecipeController { ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, })); } else { - let remoteResults = []; - if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq - remoteResults = JSON.parse(await (await fetch(`https://api.franzinfra.com/v1/recipes/search?needle=${encodeURIComponent(needle)}`)).text()); - } const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); - const localResults = localResultsArray.map((recipe) => ({ + results = localResultsArray.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, })); - - results = [ - ...localResults, - ...remoteResults || [], - ]; } return response.send(results); @@ -192,9 +183,6 @@ class RecipeController { if (await Drive.exists(`${service}.tar.gz`)) { return response.send(await Drive.get(`${service}.tar.gz`)); } - if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq - return response.redirect(`https://api.franzinfra.com/v1/recipes/download/${service}`); - } return response.status(400).send({ message: 'Recipe not found', code: 'recipe-not-found', diff --git a/app/Controllers/Http/StaticController.js b/app/Controllers/Http/StaticController.js index 4e604df..7854fd6 100644 --- a/app/Controllers/Http/StaticController.js +++ b/app/Controllers/Http/StaticController.js @@ -93,14 +93,13 @@ class StaticController { }); } - // Return list of popular recipes (copy of the response Franz's API is returning) popularRecipes({ response, }) { return response.send( fs .readJsonSync(path.join( - Helpers.appRoot(), 'officialrecipes', 'recipes', 'all.json', + Helpers.appRoot(), 'recipes', 'all.json', )) .filter((recipe) => recipe.featured), ); -- cgit v1.2.3-54-g00ecf