diff options
author | kytwb <kytwb@pm.me> | 2022-01-06 23:10:16 +0100 |
---|---|---|
committer | kytwb <kytwb@pm.me> | 2022-01-06 23:10:16 +0100 |
commit | e1cc68d8bf4d473307638607dfee98a90bc7a6be (patch) | |
tree | 0662959ae6b49f54831221c3f0d9cebd71d95a8e /app | |
parent | 1.3.1 (diff) | |
download | ferdium-server-e1cc68d8bf4d473307638607dfee98a90bc7a6be.tar.gz ferdium-server-e1cc68d8bf4d473307638607dfee98a90bc7a6be.tar.zst ferdium-server-e1cc68d8bf4d473307638607dfee98a90bc7a6be.zip |
Review recipes routes, fix download recipe response type
Diffstat (limited to 'app')
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 22 | ||||
-rw-r--r-- | app/Controllers/Http/ServiceController.js | 4 | ||||
-rw-r--r-- | app/Controllers/Http/StaticController.js | 12 |
3 files changed, 19 insertions, 19 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'); |
7 | const Env = use('Env'); | 7 | const Env = use('Env'); |
8 | 8 | ||
9 | const fetch = require('node-fetch'); | ||
10 | const targz = require('targz'); | 9 | const targz = require('targz'); |
11 | const path = require('path'); | 10 | const path = require('path'); |
12 | const fs = require('fs-extra'); | 11 | const 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', |
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js index ef8b168..3d10cb4 100644 --- a/app/Controllers/Http/ServiceController.js +++ b/app/Controllers/Http/ServiceController.js | |||
@@ -305,10 +305,6 @@ class ServiceController { | |||
305 | return response.send(servicesArray); | 305 | return response.send(servicesArray); |
306 | } | 306 | } |
307 | 307 | ||
308 | update({ response }) { | ||
309 | return response.send([]); | ||
310 | } | ||
311 | |||
312 | async delete({ params, auth, response }) { | 308 | async delete({ params, auth, response }) { |
313 | // Update data in database | 309 | // Update data in database |
314 | await Service.query() | 310 | await Service.query() |
diff --git a/app/Controllers/Http/StaticController.js b/app/Controllers/Http/StaticController.js index 7854fd6..aad1059 100644 --- a/app/Controllers/Http/StaticController.js +++ b/app/Controllers/Http/StaticController.js | |||
@@ -93,18 +93,6 @@ class StaticController { | |||
93 | }); | 93 | }); |
94 | } | 94 | } |
95 | 95 | ||
96 | popularRecipes({ | ||
97 | response, | ||
98 | }) { | ||
99 | return response.send( | ||
100 | fs | ||
101 | .readJsonSync(path.join( | ||
102 | Helpers.appRoot(), 'recipes', 'all.json', | ||
103 | )) | ||
104 | .filter((recipe) => recipe.featured), | ||
105 | ); | ||
106 | } | ||
107 | |||
108 | // Show announcements | 96 | // Show announcements |
109 | async announcement({ | 97 | async announcement({ |
110 | response, | 98 | response, |