blob: 0b9d4885f296750ffdc73fe487a1aa51e3dc672e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
'use strict'
const Recipe = use('App/Models/Recipe');
const fetch = require('node-fetch');
class RecipeController {
async list({
response
}) {
const officialRecipes = JSON.parse(await (await fetch('https://api.franzinfra.com/v1/recipes')).text());
const customRecipesArray = (await Recipe.all()).rows;
const customRecipes = customRecipesArray.map(recipe => ({
"id": recipe.recipeId,
"name": recipe.name,
...JSON.parse(recipe.data)
}))
const recipes = [
...officialRecipes,
...customRecipes,
]
return response.send(recipes)
}
}
module.exports = RecipeController
|