aboutsummaryrefslogtreecommitdiffstats
path: root/src/internal-server
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-12-02 23:57:13 +0100
committerLibravatar GitHub <noreply@github.com>2021-12-03 04:27:13 +0530
commitf64f1b3bd9bec4036748b98ff8ac0f0431749f30 (patch)
tree33691b4b02a546a7a1665ca29b18e3baa135c9ef /src/internal-server
parent5.6.4-nightly.22 [skip ci] (diff)
downloadferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.gz
ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.zst
ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.zip
chore: upgrade commitlint and eslint-plugin-unicorn to latest (#2295)
- upgrade commitlint and eslint-plugin-unicorn dependencies - update prepare-code script to run lint:fix instead of lint - fix unicorn/no-await-expression-member lint issues - various whitespace formatting fixes due to lint:fix
Diffstat (limited to 'src/internal-server')
-rw-r--r--src/internal-server/app/Controllers/Http/RecipeController.js25
-rw-r--r--src/internal-server/app/Controllers/Http/ServiceController.js32
-rw-r--r--src/internal-server/app/Controllers/Http/UserController.js7
-rw-r--r--src/internal-server/app/Controllers/Http/WorkspaceController.js13
4 files changed, 46 insertions, 31 deletions
diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js
index 1b0ac7035..7e35e6831 100644
--- a/src/internal-server/app/Controllers/Http/RecipeController.js
+++ b/src/internal-server/app/Controllers/Http/RecipeController.js
@@ -13,8 +13,10 @@ const RECIPES_URL = `${LIVE_FERDI_API}/${API_VERSION}/recipes`;
13class RecipeController { 13class RecipeController {
14 // List official and custom recipes 14 // List official and custom recipes
15 async list({ response }) { 15 async list({ response }) {
16 const officialRecipes = JSON.parse(await (await fetch(RECIPES_URL)).text()); 16 const recipesUrlFetch = await fetch(RECIPES_URL);
17 const customRecipesArray = (await Recipe.all()).rows; 17 const officialRecipes = JSON.parse(await recipesUrlFetch).text();
18 const allRecipes = await Recipe.all();
19 const customRecipesArray = allRecipes.rows;
18 const customRecipes = customRecipesArray.map(recipe => ({ 20 const customRecipes = customRecipesArray.map(recipe => ({
19 id: recipe.recipeId, 21 id: recipe.recipeId,
20 name: recipe.name, 22 name: recipe.name,
@@ -46,7 +48,8 @@ class RecipeController {
46 let results; 48 let results;
47 49
48 if (needle === 'ferdi:custom') { 50 if (needle === 'ferdi:custom') {
49 const dbResults = (await Recipe.all()).toJSON(); 51 const allRecipes = await Recipe.all();
52 const dbResults = allRecipes.toJSON();
50 results = dbResults.map(recipe => ({ 53 results = dbResults.map(recipe => ({
51 id: recipe.recipeId, 54 id: recipe.recipeId,
52 name: recipe.name, 55 name: recipe.name,
@@ -56,20 +59,18 @@ class RecipeController {
56 let remoteResults = []; 59 let remoteResults = [];
57 // eslint-disable-next-line eqeqeq 60 // eslint-disable-next-line eqeqeq
58 if (Env.get('CONNECT_WITH_FRANZ') == 'true') { 61 if (Env.get('CONNECT_WITH_FRANZ') == 'true') {
59 remoteResults = JSON.parse( 62 const recipesUrlFetch = await fetch(
60 await ( 63 `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`,
61 await fetch(
62 `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`,
63 )
64 ).text(),
65 ); 64 );
65 remoteResults = JSON.parse(await recipesUrlFetch.text());
66 } 66 }
67 67
68 debug('remoteResults:', remoteResults); 68 debug('remoteResults:', remoteResults);
69 69
70 const localResultsArray = ( 70 const recipeQuery = await Recipe.query()
71 await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch() 71 .where('name', 'LIKE', `%${needle}%`)
72 ).toJSON(); 72 .fetch();
73 const localResultsArray = recipeQuery.toJSON();
73 const localResults = localResultsArray.map(recipe => ({ 74 const localResults = localResultsArray.map(recipe => ({
74 id: recipe.recipeId, 75 id: recipe.recipeId,
75 name: recipe.name, 76 name: recipe.name,
diff --git a/src/internal-server/app/Controllers/Http/ServiceController.js b/src/internal-server/app/Controllers/Http/ServiceController.js
index c4ca5a113..a3add4464 100644
--- a/src/internal-server/app/Controllers/Http/ServiceController.js
+++ b/src/internal-server/app/Controllers/Http/ServiceController.js
@@ -34,6 +34,7 @@ class ServiceController {
34 do { 34 do {
35 serviceId = uuid(); 35 serviceId = uuid();
36 } while ( 36 } while (
37 // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member
37 (await Service.query().where('serviceId', serviceId).fetch()).rows 38 (await Service.query().where('serviceId', serviceId).fetch()).rows
38 .length > 0 39 .length > 0
39 ); 40 );
@@ -68,7 +69,8 @@ class ServiceController {
68 69
69 // List all services a user has created 70 // List all services a user has created
70 async list({ response }) { 71 async list({ response }) {
71 const services = (await Service.all()).rows; 72 const allServices = await Service.all();
73 const services = allServices.rows;
72 // Convert to array with all data Franz wants 74 // Convert to array with all data Franz wants
73 const servicesArray = services.map(service => { 75 const servicesArray = services.map(service => {
74 const settings = 76 const settings =
@@ -111,8 +113,8 @@ class ServiceController {
111 size: '2mb', 113 size: '2mb',
112 }); 114 });
113 const { id } = params; 115 const { id } = params;
114 const service = (await Service.query().where('serviceId', id).fetch()) 116 const serviceQuery = await Service.query().where('serviceId', id).fetch();
115 .rows[0]; 117 const service = serviceQuery.rows[0];
116 const settings = 118 const settings =
117 typeof service.settings === 'string' 119 typeof service.settings === 'string'
118 ? JSON.parse(service.settings) 120 ? JSON.parse(service.settings)
@@ -166,8 +168,8 @@ class ServiceController {
166 const { id } = params; 168 const { id } = params;
167 169
168 // Get current settings from db 170 // Get current settings from db
169 const serviceData = (await Service.query().where('serviceId', id).fetch()) 171 const serviceQuery = await Service.query().where('serviceId', id).fetch();
170 .rows[0]; 172 const serviceData = serviceQuery.rows[0];
171 173
172 const settings = { 174 const settings = {
173 ...(typeof serviceData.settings === 'string' 175 ...(typeof serviceData.settings === 'string'
@@ -185,8 +187,10 @@ class ServiceController {
185 }); 187 });
186 188
187 // Get updated row 189 // Get updated row
188 const service = (await Service.query().where('serviceId', id).fetch()) 190 const anotherServiceQuery = await Service.query()
189 .rows[0]; 191 .where('serviceId', id)
192 .fetch();
193 const service = anotherServiceQuery.rows[0];
190 194
191 return response.send({ 195 return response.send({
192 data: { 196 data: {
@@ -218,11 +222,12 @@ class ServiceController {
218 222
219 for (const service of Object.keys(data)) { 223 for (const service of Object.keys(data)) {
220 // Get current settings from db 224 // Get current settings from db
221 const serviceData = ( 225 // eslint-disable-next-line no-await-in-loop
222 await Service.query() // eslint-disable-line no-await-in-loop 226 const serviceQuery = await Service.query()
223 .where('serviceId', service) 227 .where('serviceId', service)
224 .fetch() 228 .fetch();
225 ).rows[0]; 229
230 const serviceData = serviceQuery.rows[0];
226 231
227 const settings = { 232 const settings = {
228 ...JSON.parse(serviceData.settings), 233 ...JSON.parse(serviceData.settings),
@@ -238,7 +243,8 @@ class ServiceController {
238 } 243 }
239 244
240 // Get new services 245 // Get new services
241 const services = (await Service.all()).rows; 246 const allServices = await Service.all();
247 const services = allServices.rows;
242 // Convert to array with all data Franz wants 248 // Convert to array with all data Franz wants
243 const servicesArray = services.map(service => { 249 const servicesArray = services.map(service => {
244 const settings = 250 const settings =
diff --git a/src/internal-server/app/Controllers/Http/UserController.js b/src/internal-server/app/Controllers/Http/UserController.js
index 2ecc8241c..abfbc2470 100644
--- a/src/internal-server/app/Controllers/Http/UserController.js
+++ b/src/internal-server/app/Controllers/Http/UserController.js
@@ -1,3 +1,4 @@
1/* eslint-disable no-await-in-loop, unicorn/no-await-expression-member */
1const User = use('App/Models/User'); 2const User = use('App/Models/User');
2const Service = use('App/Models/Service'); 3const Service = use('App/Models/Service');
3const Workspace = use('App/Models/Workspace'); 4const Workspace = use('App/Models/Workspace');
@@ -230,8 +231,10 @@ class UserController {
230 auth, 231 auth,
231 response, 232 response,
232 }) { 233 }) {
233 const services = (await Service.all()).toJSON(); 234 const allServices = await Service.all();
234 const workspaces = (await Workspace.all()).toJSON(); 235 const services = allServices.toJSON();
236 const allWorkspaces = await Workspace.all();
237 const workspaces = allWorkspaces.toJSON();
235 238
236 const exportData = { 239 const exportData = {
237 username: 'Ferdi', 240 username: 'Ferdi',
diff --git a/src/internal-server/app/Controllers/Http/WorkspaceController.js b/src/internal-server/app/Controllers/Http/WorkspaceController.js
index 528721f13..9ba2b174e 100644
--- a/src/internal-server/app/Controllers/Http/WorkspaceController.js
+++ b/src/internal-server/app/Controllers/Http/WorkspaceController.js
@@ -25,11 +25,13 @@ class WorkspaceController {
25 do { 25 do {
26 workspaceId = uuid(); 26 workspaceId = uuid();
27 } while ( 27 } while (
28 // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member
28 (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows 29 (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows
29 .length > 0 30 .length > 0
30 ); 31 );
31 32
32 const order = (await Workspace.all()).rows.length; 33 const allWorkspaces = await Workspace.all();
34 const order = allWorkspaces.rows.length;
33 const { name } = data; 35 const { name } = data;
34 delete data.name; 36 delete data.name;
35 37
@@ -76,8 +78,10 @@ class WorkspaceController {
76 }); 78 });
77 79
78 // Get updated row 80 // Get updated row
79 const workspace = (await Workspace.query().where('workspaceId', id).fetch()) 81 const workspaceQuery = await Workspace.query()
80 .rows[0]; 82 .where('workspaceId', id)
83 .fetch();
84 const workspace = workspaceQuery.rows[0];
81 85
82 return response.send({ 86 return response.send({
83 id: workspace.workspaceId, 87 id: workspace.workspaceId,
@@ -118,7 +122,8 @@ class WorkspaceController {
118 122
119 // List all workspaces a user has created 123 // List all workspaces a user has created
120 async list({ response }) { 124 async list({ response }) {
121 const workspaces = (await Workspace.all()).rows; 125 const allWorkspaces = await Workspace.all();
126 const workspaces = allWorkspaces.rows;
122 // Convert to array with all data Franz wants 127 // Convert to array with all data Franz wants
123 let workspacesArray = []; 128 let workspacesArray = [];
124 if (workspaces) { 129 if (workspaces) {