aboutsummaryrefslogtreecommitdiffstats
path: root/app/Controllers/Http/RecipeController.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-08-23 14:04:22 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-08-23 14:04:22 +0200
commit5970b8e5bbf993c88c1f901708a7c5075a916770 (patch)
tree11636435cba3414a930b4a81f9bf7ca8d4de31e1 /app/Controllers/Http/RecipeController.js
parentFix user login (diff)
downloadferdium-server-5970b8e5bbf993c88c1f901708a7c5075a916770.tar.gz
ferdium-server-5970b8e5bbf993c88c1f901708a7c5075a916770.tar.zst
ferdium-server-5970b8e5bbf993c88c1f901708a7c5075a916770.zip
Add support for workspaces
Diffstat (limited to 'app/Controllers/Http/RecipeController.js')
-rw-r--r--app/Controllers/Http/RecipeController.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js
new file mode 100644
index 0000000..0b9d488
--- /dev/null
+++ b/app/Controllers/Http/RecipeController.js
@@ -0,0 +1,27 @@
1'use strict'
2
3const Recipe = use('App/Models/Recipe');
4const fetch = require('node-fetch');
5
6class RecipeController {
7 async list({
8 response
9 }) {
10 const officialRecipes = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes')).text());
11 const customRecipesArray = (await Recipe.all()).rows;
12 const customRecipes = customRecipesArray.map(recipe => ({
13 "id": recipe.recipeId,
14 "name": recipe.name,
15 ...JSON.parse(recipe.data)
16 }))
17
18 const recipes = [
19 ...officialRecipes,
20 ...customRecipes,
21 ]
22
23 return response.send(recipes)
24 }
25}
26
27module.exports = RecipeController