diff options
Diffstat (limited to 'app/Controllers/Http/RecipeController.js')
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 12 |
1 files changed, 10 insertions, 2 deletions
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 { | |||
140 | const needle = request.input('needle') | 140 | const needle = request.input('needle') |
141 | 141 | ||
142 | // Get results | 142 | // Get results |
143 | const remoteResults = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes/search?needle=' + encodeURIComponent(needle))).text()); | 143 | let remoteResults = []; |
144 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { | ||
145 | remoteResults = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes/search?needle=' + encodeURIComponent(needle))).text()); | ||
146 | } | ||
144 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', '%' + needle + '%').fetch()).toJSON(); | 147 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', '%' + needle + '%').fetch()).toJSON(); |
145 | const localResults = localResultsArray.map(recipe => ({ | 148 | const localResults = localResultsArray.map(recipe => ({ |
146 | "id": recipe.recipeId, | 149 | "id": recipe.recipeId, |
@@ -184,8 +187,13 @@ class RecipeController { | |||
184 | // Check if recipe exists in recipes folder | 187 | // Check if recipe exists in recipes folder |
185 | if (await Drive.exists(service + '.tar.gz')) { | 188 | if (await Drive.exists(service + '.tar.gz')) { |
186 | response.send(await Drive.get(service + '.tar.gz')) | 189 | response.send(await Drive.get(service + '.tar.gz')) |
187 | } else { | 190 | } else if(Env.get('CONNECT_WITH_FRANZ') == 'true') { |
188 | response.redirect('https://api.franzinfra.com/v1/recipes/download/' + service) | 191 | response.redirect('https://api.franzinfra.com/v1/recipes/download/' + service) |
192 | } else { | ||
193 | return response.status(400).send({ | ||
194 | "message": "Recipe not found", | ||
195 | "code": "recipe-not-found" | ||
196 | }) | ||
189 | } | 197 | } |
190 | } | 198 | } |
191 | } | 199 | } |