From 7e6f215598c14bf20f68ea400c0d8fb654328733 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 24 May 2021 16:20:02 +0100 Subject: [PATCH] Linting and fixing an issue with the dev pass through. --- packages/auth/src/redis/index.js | 5 ----- packages/server/src/api/controllers/dev.js | 9 +++++++++ packages/worker/src/api/controllers/admin/configs.js | 9 +-------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/auth/src/redis/index.js b/packages/auth/src/redis/index.js index 7a1b9a3431..0a21966301 100644 --- a/packages/auth/src/redis/index.js +++ b/packages/auth/src/redis/index.js @@ -4,17 +4,12 @@ const Redis = env.isTest() ? require("ioredis-mock") : require("ioredis") const { addDbPrefix, removeDbPrefix, getRedisOptions } = require("./utils") const RETRY_PERIOD_MS = 2000 -const MAX_RETRIES = 20 const CLUSTERED = false // for testing just generate the client once let CONNECTED = false let CLIENT = env.isTest() ? new Redis(getRedisOptions()) : null -function retryConnection() { - setTimeout(init, RETRY_PERIOD_MS) -} - /** * Inits the system, will error if unable to connect to redis cluster (may take up to 10 seconds) otherwise * will return the ioredis client which will be ready to use. diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index 2e90fb83e7..068e1e59c0 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -23,7 +23,16 @@ async function redirect(ctx, method) { if (cookie) { ctx.set("set-cookie", cookie) } + let body + try { + body = await response.json() + } catch (err) { + // don't worry about errors, likely no JSON + } ctx.status = response.status + if (body) { + ctx.body = body + } ctx.cookies } diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index 8a6788cdfd..82466249a2 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -6,10 +6,8 @@ const { getGlobalUserParams, getScopedFullConfig, } = require("@budibase/auth").db -const fetch = require("node-fetch") const { Configs } = require("../../../constants") const email = require("../../../utilities/email") -const env = require("../../../environment") const { upload, ObjectStoreBuckets } = require("@budibase/auth").objectStore const APP_PREFIX = "app_" @@ -155,12 +153,7 @@ exports.configChecklist = async function (ctx) { // TODO: Watch get started video // Apps exist - let allDbs - if (env.COUCH_DB_URL) { - allDbs = await (await fetch(`${env.COUCH_DB_URL}/_all_dbs`)).json() - } else { - allDbs = await CouchDB.allDbs() - } + let allDbs = await CouchDB.allDbs() const appDbNames = allDbs.filter(dbName => dbName.startsWith(APP_PREFIX)) // They have set up SMTP