diff options
author | vantezzen <properly@protonmail.com> | 2019-08-23 14:04:22 +0200 |
---|---|---|
committer | vantezzen <properly@protonmail.com> | 2019-08-23 14:04:22 +0200 |
commit | 5970b8e5bbf993c88c1f901708a7c5075a916770 (patch) | |
tree | 11636435cba3414a930b4a81f9bf7ca8d4de31e1 /app/Controllers/Http/RecipeController.js | |
parent | Fix user login (diff) | |
download | ferdium-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.js | 27 |
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 | |||
3 | const Recipe = use('App/Models/Recipe'); | ||
4 | const fetch = require('node-fetch'); | ||
5 | |||
6 | class 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 | |||
27 | module.exports = RecipeController | ||