From 9eedd8a01c32b261a71716935f1aaee6daff81bf Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 21 Aug 2021 13:46:06 +0530 Subject: refactor: add debug statements [skip ci] --- src/internal-server/app/Controllers/Http/RecipeController.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/internal-server/app/Controllers/Http') diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index 8a6b4f684..df889c7f4 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js @@ -6,8 +6,10 @@ const { const Env = use('Env'); const fetch = require('node-fetch'); +const debug = require('debug')('Ferdi:internalServer:RecipeController'); +const { LIVE_FERDI_API } = require('../../../../config'); -const RECIPES_URL = 'https://api.getferdi.com/v1/recipes'; +const RECIPES_URL = `${LIVE_FERDI_API}/v1/recipes`; class RecipeController { // List official and custom recipes @@ -64,6 +66,9 @@ class RecipeController { if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq remoteResults = JSON.parse(await (await fetch(`${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`)).text()); } + + debug('remoteResults:', remoteResults); + const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); const localResults = localResultsArray.map(recipe => ({ id: recipe.recipeId, @@ -71,6 +76,8 @@ class RecipeController { ...JSON.parse(recipe.data), })); + debug('localResults:', localResults); + results = [ ...localResults, ...remoteResults || [], -- cgit v1.2.3-54-g00ecf