From f8277e2e3a736a75e9174d55fec816dff04b2aae Mon Sep 17 00:00:00 2001 From: kytwb Date: Wed, 5 Jan 2022 17:10:50 +0100 Subject: Replace hard-coded popular services in internal server --- .../app/Controllers/Http/RecipeController.js | 15 ++ .../app/Controllers/Http/StaticController.js | 165 --------------------- 2 files changed, 15 insertions(+), 165 deletions(-) (limited to 'src/internal-server/app') diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index d7ca716bb..daa9356f6 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js @@ -85,6 +85,21 @@ class RecipeController { return response.send(results); } + // Return an empty array + update({ + response, + }) { + return response.send([]); + } + + async popularRecipes({ + response, + }) { + const recipesUrlFetch = await fetch(`${RECIPES_URL}/popular`); + const featuredRecipes = JSON.parse(await recipesUrlFetch.text()); + return response.send(featuredRecipes); + } + // Download a recipe async download({ response, params }) { // Validate user input diff --git a/src/internal-server/app/Controllers/Http/StaticController.js b/src/internal-server/app/Controllers/Http/StaticController.js index ef5764881..99723940a 100644 --- a/src/internal-server/app/Controllers/Http/StaticController.js +++ b/src/internal-server/app/Controllers/Http/StaticController.js @@ -19,171 +19,6 @@ class StaticController { }); } - // Return an empty array - emptyArray({ - response, - }) { - return response.send([]); - } - - // Return list of popular recipes (copy of the response Franz's API is returning) - popularRecipes({ - response, - }) { - return response.send([{ - // TODO: Why is this list hardcoded? - author: 'Stefan Malzner ', - featured: false, - id: 'slack', - name: 'Slack', - version: '1.0.4', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'whatsapp', - name: 'WhatsApp', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'messenger', - name: 'Messenger', - version: '1.0.6', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'telegram', - name: 'Telegram', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'gmail', - name: 'Gmail', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'skype', - name: 'Skype', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'hangouts', - name: 'Hangouts', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'discord', - name: 'Discord', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'tweetdeck', - name: 'Tweetdeck', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'hipchat', - name: 'HipChat', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'rocketchat', - name: 'Rocket.Chat', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.svg', - }, - }, { - author: 'Brian Gilbert ', - featured: false, - id: 'gitter', - name: 'Gitter', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'mattermost', - name: 'Mattermost', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.svg', - }, - }, { - author: 'Franz ', - featured: false, - id: 'toggl', - name: 'Toggl', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.svg', - }, - }, { - author: 'Stuart Clark ', - featured: false, - id: 'twist', - name: 'Twist', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.svg', - }, - }]); - } - // Show announcements announcement({ response, -- cgit v1.2.3-54-g00ecf