aboutsummaryrefslogtreecommitdiffstats
path: root/app/Controllers/Http/RecipeController.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers/Http/RecipeController.js')
-rw-r--r--app/Controllers/Http/RecipeController.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js
index 066728f..a2b129d 100644
--- a/app/Controllers/Http/RecipeController.js
+++ b/app/Controllers/Http/RecipeController.js
@@ -6,7 +6,6 @@ const {
6} = use('Validator'); 6} = use('Validator');
7const Env = use('Env'); 7const Env = use('Env');
8 8
9const fetch = require('node-fetch');
10const targz = require('targz'); 9const targz = require('targz');
11const path = require('path'); 10const path = require('path');
12const fs = require('fs-extra'); 11const fs = require('fs-extra');
@@ -90,7 +89,7 @@ class RecipeController {
90 89
91 // Compress files to .tar.gz file 90 // Compress files to .tar.gz file
92 const source = Helpers.tmpPath('recipe'); 91 const source = Helpers.tmpPath('recipe');
93 const destination = path.join(Helpers.appRoot(), `/recipes/${data.id}.tar.gz`); 92 const destination = path.join(Helpers.appRoot(), `/recipes/recipes/${data.id}.tar.gz`);
94 93
95 compress( 94 compress(
96 source, 95 source,
@@ -155,6 +154,22 @@ class RecipeController {
155 return response.send(results); 154 return response.send(results);
156 } 155 }
157 156
157 popularRecipes({
158 response,
159 }) {
160 return response.send(
161 fs
162 .readJsonSync(path.join(
163 Helpers.appRoot(), 'recipes', 'all.json',
164 ))
165 .filter((recipe) => recipe.featured),
166 );
167 }
168
169 update({ response }) {
170 return response.send([]);
171 }
172
158 // Download a recipe 173 // Download a recipe
159 async download({ 174 async download({
160 response, 175 response,
@@ -181,8 +196,9 @@ class RecipeController {
181 196
182 // Check if recipe exists in recipes folder 197 // Check if recipe exists in recipes folder
183 if (await Drive.exists(`${service}.tar.gz`)) { 198 if (await Drive.exists(`${service}.tar.gz`)) {
184 return response.send(await Drive.get(`${service}.tar.gz`)); 199 return response.type('.tar.gz').send(await Drive.get(`${service}.tar.gz`));
185 } 200 }
201
186 return response.status(400).send({ 202 return response.status(400).send({
187 message: 'Recipe not found', 203 message: 'Recipe not found',
188 code: 'recipe-not-found', 204 code: 'recipe-not-found',