From 6a9a42e50dfc9e7811e0b75da6b3ea456372d75e Mon Sep 17 00:00:00 2001 From: vantezzen Date: Tue, 3 Sep 2019 10:34:42 +0200 Subject: Add CONNECT_WITH_FRANZ option --- app/Controllers/Http/RecipeController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/Controllers/Http/RecipeController.js') diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index ec0cde9..fd9ed83 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js @@ -140,7 +140,10 @@ class RecipeController { const needle = request.input('needle') // Get results - const remoteResults = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes/search?needle=' + encodeURIComponent(needle))).text()); + let remoteResults = []; + if (Env.get('CONNECT_WITH_FRANZ') == 'true') { + 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 => ({ "id": recipe.recipeId, @@ -184,8 +187,13 @@ class RecipeController { // Check if recipe exists in recipes folder if (await Drive.exists(service + '.tar.gz')) { response.send(await Drive.get(service + '.tar.gz')) - } else { + } else if(Env.get('CONNECT_WITH_FRANZ') == 'true') { response.redirect('https://api.franzinfra.com/v1/recipes/download/' + service) + } else { + return response.status(400).send({ + "message": "Recipe not found", + "code": "recipe-not-found" + }) } } } -- cgit v1.2.3-70-g09d2