diff options
-rw-r--r-- | .gitmodules | 2 | ||||
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 16 | ||||
-rw-r--r-- | app/Controllers/Http/StaticController.js | 3 | ||||
m--------- | officialrecipes/recipes | 0 | ||||
m--------- | recipes | 0 |
5 files changed, 4 insertions, 17 deletions
diff --git a/.gitmodules b/.gitmodules index c3c216b..5a8d15f 100644 --- a/.gitmodules +++ b/.gitmodules | |||
@@ -1,3 +1,3 @@ | |||
1 | [submodule "recipes"] | 1 | [submodule "recipes"] |
2 | path = officialrecipes/recipes | 2 | path = recipes |
3 | url = https://github.com/getferdi/recipes | 3 | url = https://github.com/getferdi/recipes |
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 { | |||
29 | async list({ | 29 | async list({ |
30 | response, | 30 | response, |
31 | }) { | 31 | }) { |
32 | const officialRecipes = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes')).text()); | 32 | const officialRecipes = fs.readJsonSync(path.join(Helpers.appRoot(), 'recipes', 'all.json')); |
33 | const customRecipesArray = (await Recipe.all()).rows; | 33 | const customRecipesArray = (await Recipe.all()).rows; |
34 | const customRecipes = customRecipesArray.map((recipe) => ({ | 34 | const customRecipes = customRecipesArray.map((recipe) => ({ |
35 | id: recipe.recipeId, | 35 | id: recipe.recipeId, |
@@ -144,21 +144,12 @@ class RecipeController { | |||
144 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, | 144 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, |
145 | })); | 145 | })); |
146 | } else { | 146 | } else { |
147 | let remoteResults = []; | ||
148 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq | ||
149 | remoteResults = JSON.parse(await (await fetch(`https://api.franzinfra.com/v1/recipes/search?needle=${encodeURIComponent(needle)}`)).text()); | ||
150 | } | ||
151 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); | 147 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); |
152 | const localResults = localResultsArray.map((recipe) => ({ | 148 | results = localResultsArray.map((recipe) => ({ |
153 | id: recipe.recipeId, | 149 | id: recipe.recipeId, |
154 | name: recipe.name, | 150 | name: recipe.name, |
155 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, | 151 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, |
156 | })); | 152 | })); |
157 | |||
158 | results = [ | ||
159 | ...localResults, | ||
160 | ...remoteResults || [], | ||
161 | ]; | ||
162 | } | 153 | } |
163 | 154 | ||
164 | return response.send(results); | 155 | return response.send(results); |
@@ -192,9 +183,6 @@ class RecipeController { | |||
192 | if (await Drive.exists(`${service}.tar.gz`)) { | 183 | if (await Drive.exists(`${service}.tar.gz`)) { |
193 | return response.send(await Drive.get(`${service}.tar.gz`)); | 184 | return response.send(await Drive.get(`${service}.tar.gz`)); |
194 | } | 185 | } |
195 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq | ||
196 | return response.redirect(`https://api.franzinfra.com/v1/recipes/download/${service}`); | ||
197 | } | ||
198 | return response.status(400).send({ | 186 | return response.status(400).send({ |
199 | message: 'Recipe not found', | 187 | message: 'Recipe not found', |
200 | code: 'recipe-not-found', | 188 | 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 { | |||
93 | }); | 93 | }); |
94 | } | 94 | } |
95 | 95 | ||
96 | // Return list of popular recipes (copy of the response Franz's API is returning) | ||
97 | popularRecipes({ | 96 | popularRecipes({ |
98 | response, | 97 | response, |
99 | }) { | 98 | }) { |
100 | return response.send( | 99 | return response.send( |
101 | fs | 100 | fs |
102 | .readJsonSync(path.join( | 101 | .readJsonSync(path.join( |
103 | Helpers.appRoot(), 'officialrecipes', 'recipes', 'all.json', | 102 | Helpers.appRoot(), 'recipes', 'all.json', |
104 | )) | 103 | )) |
105 | .filter((recipe) => recipe.featured), | 104 | .filter((recipe) => recipe.featured), |
106 | ); | 105 | ); |
diff --git a/officialrecipes/recipes b/officialrecipes/recipes deleted file mode 160000 | |||
Subproject 34f764eff2b8262856b93c127d9f65449587173 | |||
diff --git a/recipes b/recipes new file mode 160000 | |||
Subproject b560ff693c244b6028bf7c74c9be3a9fac78406 | |||