diff options
Diffstat (limited to 'src/internal-server/app/Controllers/Http/ServiceController.js')
-rw-r--r-- | src/internal-server/app/Controllers/Http/ServiceController.js | 32 |
1 files changed, 19 insertions, 13 deletions
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 = |