From 0ecb26fcc0d1358efeafc1512dfb67ac6695382b Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 10 Mar 2020 15:07:46 +0100 Subject: Fix lint --- app/Controllers/Http/DashboardController.js | 10 +-- app/Controllers/Http/RecipeController.js | 9 +-- app/Controllers/Http/ServiceController.js | 103 ++++++++++++++-------------- app/Controllers/Http/StaticController.js | 36 +++++----- app/Controllers/Http/UserController.js | 8 +-- app/Controllers/Http/WorkspaceController.js | 2 +- 6 files changed, 84 insertions(+), 84 deletions(-) (limited to 'app') diff --git a/app/Controllers/Http/DashboardController.js b/app/Controllers/Http/DashboardController.js index fe179c9..1018f78 100644 --- a/app/Controllers/Http/DashboardController.js +++ b/app/Controllers/Http/DashboardController.js @@ -166,7 +166,7 @@ class DashboardController { session, response, }) { - let validation = await validateAll(request.all(), { + const validation = await validateAll(request.all(), { file: 'required', }); if (validation.fails()) { @@ -177,14 +177,14 @@ class DashboardController { let file; try { file = JSON.parse(request.input('file')); - } catch(e) { - session.flash({ type: 'danger', message: 'Invalid Ferdi account file' }) + } catch (e) { + session.flash({ type: 'danger', message: 'Invalid Ferdi account file' }); return response.redirect('back'); } console.log(file); - if(!file || !file.services || !file.workspaces) { - session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' }) + if (!file || !file.services || !file.workspaces) { + session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' }); return response.redirect('back'); } diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 6c8aa21..9bfd92e 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js @@ -35,7 +35,7 @@ class RecipeController { const customRecipes = customRecipesArray.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, + ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, })); const recipes = [ @@ -144,7 +144,7 @@ class RecipeController { results = dbResults.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, + ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, })); } else { let remoteResults = []; @@ -155,7 +155,7 @@ class RecipeController { const localResults = localResultsArray.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, + ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, })); results = [ @@ -194,7 +194,8 @@ class RecipeController { // Check if recipe exists in recipes folder if (await Drive.exists(`${service}.tar.gz`)) { return response.send(await Drive.get(`${service}.tar.gz`)); - } else if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq + } + if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq return response.redirect(`https://api.franzinfra.com/v1/recipes/download/${service}`); } return response.status(400).send({ diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js index 90055b6..a1d26cb 100644 --- a/app/Controllers/Http/ServiceController.js +++ b/app/Controllers/Http/ServiceController.js @@ -86,7 +86,7 @@ class ServiceController { const services = (await auth.user.services().fetch()).rows; // Convert to array with all data Franz wants const servicesArray = services.map((service) => { - const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; + const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; return { customRecipe: false, @@ -105,7 +105,7 @@ class ServiceController { name: service.name, recipeId: service.recipeId, userId: auth.user.id, - } + }; }); return response.send(servicesArray); @@ -127,7 +127,7 @@ class ServiceController { // Upload custom service icon const icon = request.file('icon', { types: ['image'], - size: '2mb' + size: '2mb', }); const { id, @@ -135,17 +135,17 @@ class ServiceController { const service = (await Service.query() .where('serviceId', id) .where('userId', auth.user.id).fetch()).rows[0]; - const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; + const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; let iconId; do { iconId = uuid() + uuid(); - } while(await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId))); - + } while (await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId))); + await icon.move(Helpers.tmpPath('uploads'), { name: iconId, - overwrite: true - }) + overwrite: true, + }); if (!icon.moved()) { return response.status(500).send(icon.error()); @@ -175,49 +175,48 @@ class ServiceController { iconUrl: `${Env.get('APP_URL')}/v1/icon/${newSettings.iconId}`, userId: auth.user.id, }, - status: ["updated"] + status: ['updated'], }); - } else { - // Update service info - const data = request.all(); - const { - id, - } = params; + } + // Update service info + const data = request.all(); + const { + id, + } = params; - // Get current settings from db - const serviceData = (await Service.query() - .where('serviceId', id) - .where('userId', auth.user.id).fetch()).rows[0]; + // Get current settings from db + const serviceData = (await Service.query() + .where('serviceId', id) + .where('userId', auth.user.id).fetch()).rows[0]; - const settings = { - ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, - ...data, - }; + const settings = { + ...typeof serviceData.settings === 'string' ? JSON.parse(serviceData.settings) : serviceData.settings, + ...data, + }; - // Update data in database - await (Service.query() - .where('serviceId', id) - .where('userId', auth.user.id)).update({ - name: data.name, - settings: JSON.stringify(settings), - }); + // Update data in database + await (Service.query() + .where('serviceId', id) + .where('userId', auth.user.id)).update({ + name: data.name, + settings: JSON.stringify(settings), + }); - // Get updated row - const service = (await Service.query() - .where('serviceId', id) - .where('userId', auth.user.id).fetch()).rows[0]; + // Get updated row + const service = (await Service.query() + .where('serviceId', id) + .where('userId', auth.user.id).fetch()).rows[0]; - return response.send({ - data: { - id, - name: service.name, - ...settings, - iconUrl: `${Env.get('APP_URL')}/v1/icon/${settings.iconId}`, - userId: auth.user.id, - }, - status: ["updated"] - }); - } + return response.send({ + data: { + id, + name: service.name, + ...settings, + iconUrl: `${Env.get('APP_URL')}/v1/icon/${settings.iconId}`, + userId: auth.user.id, + }, + status: ['updated'], + }); } async icon({ @@ -231,7 +230,7 @@ class ServiceController { const iconPath = path.join(Helpers.tmpPath('uploads'), id); if (!await fs.exists(iconPath)) { return response.status(404).send({ - status: 'Icon doesn\'t exist' + status: 'Icon doesn\'t exist', }); } @@ -252,7 +251,7 @@ class ServiceController { .where('userId', auth.user.id).fetch()).rows[0]; const settings = { - ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, + ...typeof serviceData.settings === 'string' ? JSON.parse(serviceData.settings) : serviceData.settings, order: data[service], }; @@ -260,16 +259,16 @@ class ServiceController { await (Service.query() // eslint-disable-line no-await-in-loop .where('serviceId', service) .where('userId', auth.user.id)) - .update({ - settings: JSON.stringify(settings), - }); + .update({ + settings: JSON.stringify(settings), + }); } // Get new services const services = (await auth.user.services().fetch()).rows; // Convert to array with all data Franz wants const servicesArray = services.map((service) => { - const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; + const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; return { customRecipe: false, @@ -288,7 +287,7 @@ class ServiceController { name: service.name, recipeId: service.recipeId, userId: auth.user.id, - } + }; }); return response.send(servicesArray); diff --git a/app/Controllers/Http/StaticController.js b/app/Controllers/Http/StaticController.js index 265578f..cd38b13 100644 --- a/app/Controllers/Http/StaticController.js +++ b/app/Controllers/Http/StaticController.js @@ -31,44 +31,44 @@ class StaticController { isTeamManagementIncludedInCurrentPlan: true, isTodosEnabled: true, isTodosIncludedInCurrentPlan: true, - defaultTrialPlan: "franz-pro-yearly", - subscribeURL: "https://getferdi.com", - planSelectionURL: "https://getferdi.com", + defaultTrialPlan: 'franz-pro-yearly', + subscribeURL: 'https://getferdi.com', + planSelectionURL: 'https://getferdi.com', isMagicBarEnabled: true, hasInlineCheckout: true, isPlanSelectionEnabled: false, isTrialStatusBarEnabled: false, canSkipTrial: true, pricingConfig: { - currency: "$", - currencyID: "USD", + currency: '$', + currencyID: 'USD', plans: { personal: { monthly: { - id: "ferdi-free", + id: 'ferdi-free', price: 0, - billed: 0 + billed: 0, }, yearly: { - id: "ferdi-completely-free", + id: 'ferdi-completely-free', price: 0, - billed: 0 - } + billed: 0, + }, }, pro: { monthly: { - id: "ferdi-still-free", + id: 'ferdi-still-free', price: 0, - billed: 0 + billed: 0, }, yearly: { - id: "ferdi-forever-free", + id: 'ferdi-forever-free', price: 0, - billed: 0 - } - } - } - } + billed: 0, + }, + }, + }, + }, }); } diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index edfccf2..979e78a 100644 --- a/app/Controllers/Http/UserController.js +++ b/app/Controllers/Http/UserController.js @@ -155,17 +155,17 @@ class UserController { async updateMe({ request, response, - auth + auth, }) { let settings = auth.user.settings || {}; if (typeof settings === 'string') { settings = JSON.parse(settings); } - let newSettings = { + const newSettings = { ...settings, ...request.all(), - } + }; auth.user.settings = JSON.stringify(newSettings); await auth.user.save(); @@ -188,7 +188,7 @@ class UserController { }, status: [ 'data-updated', - ] + ], }); } diff --git a/app/Controllers/Http/WorkspaceController.js b/app/Controllers/Http/WorkspaceController.js index dc02e44..7be0e5b 100644 --- a/app/Controllers/Http/WorkspaceController.js +++ b/app/Controllers/Http/WorkspaceController.js @@ -168,7 +168,7 @@ class WorkspaceController { id: workspace.workspaceId, name: workspace.name, order: workspace.order, - services: typeof workspace.services === "string" ? JSON.parse(workspace.services) : workspace.services, + services: typeof workspace.services === 'string' ? JSON.parse(workspace.services) : workspace.services, userId: auth.user.id, })); } -- cgit v1.2.3-54-g00ecf