From 75ae7ac8d61e67d4ece982b080c299f20fd6f76d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 2 Aug 2021 18:36:32 +0100 Subject: [PATCH] Linting. --- packages/auth/src/db/constants.js | 2 +- packages/auth/src/db/utils.js | 1 - packages/auth/src/middleware/matchers.js | 2 +- packages/auth/src/middleware/tenancy.js | 5 +---- packages/auth/src/tenancy/context.js | 2 +- packages/auth/src/tenancy/tenancy.js | 4 ++-- packages/auth/src/utils.js | 6 +----- packages/server/src/api/index.js | 3 ++- .../worker/src/api/controllers/global/auth.js | 6 +++++- .../worker/src/api/controllers/global/email.js | 11 ++--------- .../worker/src/api/controllers/global/users.js | 17 ++++++++++------- .../src/api/controllers/global/workspaces.js | 5 +---- packages/worker/src/api/index.js | 5 +++-- .../worker/src/constants/templates/index.js | 4 +--- packages/worker/src/utilities/email.js | 7 +------ packages/worker/src/utilities/templates.js | 4 +--- 16 files changed, 33 insertions(+), 51 deletions(-) diff --git a/packages/auth/src/db/constants.js b/packages/auth/src/db/constants.js index 227d793f3e..77643ce4c5 100644 --- a/packages/auth/src/db/constants.js +++ b/packages/auth/src/db/constants.js @@ -14,4 +14,4 @@ exports.StaticDatabases = { tenants: "tenants", }, }, -} \ No newline at end of file +} diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index e53cb01123..7d3a69ccd7 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -1,6 +1,5 @@ const { newid } = require("../hashing") const Replication = require("./Replication") -const { getDB } = require("./index") const { DEFAULT_TENANT_ID } = require("../constants") const env = require("../environment") const { StaticDatabases, SEPARATOR } = require("./constants") diff --git a/packages/auth/src/middleware/matchers.js b/packages/auth/src/middleware/matchers.js index 79b14bc99d..f46f0d781b 100644 --- a/packages/auth/src/middleware/matchers.js +++ b/packages/auth/src/middleware/matchers.js @@ -27,4 +27,4 @@ exports.matches = (ctx, options) => { return urlMatch && methodMatch }) -} \ No newline at end of file +} diff --git a/packages/auth/src/middleware/tenancy.js b/packages/auth/src/middleware/tenancy.js index 3a1df833c1..9242f11c26 100644 --- a/packages/auth/src/middleware/tenancy.js +++ b/packages/auth/src/middleware/tenancy.js @@ -1,7 +1,4 @@ -const { - createTenancyContext, - setTenantId, -} = require("../tenancy") +const { createTenancyContext, setTenantId } = require("../tenancy") const { buildMatcherRegex, matches } = require("./matchers") module.exports = (allowQueryStringPatterns, noTenancyPatterns) => { diff --git a/packages/auth/src/tenancy/context.js b/packages/auth/src/tenancy/context.js index 1331dd0a35..5210700bd0 100644 --- a/packages/auth/src/tenancy/context.js +++ b/packages/auth/src/tenancy/context.js @@ -84,4 +84,4 @@ exports.getTenantId = () => { throw Error("Tenant id not found") } return tenantId -} \ No newline at end of file +} diff --git a/packages/auth/src/tenancy/tenancy.js b/packages/auth/src/tenancy/tenancy.js index 3c1c145938..16dedd3ebf 100644 --- a/packages/auth/src/tenancy/tenancy.js +++ b/packages/auth/src/tenancy/tenancy.js @@ -76,7 +76,7 @@ exports.getGlobalDB = (tenantId = null) => { // tenant ID can be set externally, for example user API where // new tenants are being created, this may be the case if (!tenantId) { - const tenantId = getTenantId() + tenantId = getTenantId() } let dbName @@ -102,4 +102,4 @@ exports.lookupTenantId = async userId => { // just return the default } return tenantId -} \ No newline at end of file +} diff --git a/packages/auth/src/utils.js b/packages/auth/src/utils.js index eee9de72fe..5936948fd7 100644 --- a/packages/auth/src/utils.js +++ b/packages/auth/src/utils.js @@ -1,8 +1,4 @@ -const { - DocumentTypes, - SEPARATOR, - ViewNames, -} = require("./db/utils") +const { DocumentTypes, SEPARATOR, ViewNames } = require("./db/utils") const jwt = require("jsonwebtoken") const { options } = require("./middleware/passport/jwt") const { createUserEmailView } = require("./db/views") diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index 8c940a5a50..13fb7efd1d 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -1,5 +1,6 @@ const Router = require("@koa/router") -const { buildAuthMiddleware, auditLog, buildTenancyMiddleware } = require("@budibase/auth").auth +const { buildAuthMiddleware, auditLog, buildTenancyMiddleware } = + require("@budibase/auth").auth const currentApp = require("../middleware/currentapp") const compress = require("koa-compress") const zlib = require("zlib") diff --git a/packages/worker/src/api/controllers/global/auth.js b/packages/worker/src/api/controllers/global/auth.js index 4f02838282..b08d51e642 100644 --- a/packages/worker/src/api/controllers/global/auth.js +++ b/packages/worker/src/api/controllers/global/auth.js @@ -8,7 +8,11 @@ const { setCookie, getCookie, clearCookie, getGlobalUserByEmail, hash } = const { Cookies } = authPkg.constants const { passport } = authPkg.auth const { checkResetPasswordCode } = require("../../../utilities/redis") -const { getGlobalDB, getTenantId, isMultiTenant } = require("@budibase/auth/tenancy") +const { + getGlobalDB, + getTenantId, + isMultiTenant, +} = require("@budibase/auth/tenancy") const env = require("../../../environment") function googleCallbackUrl() { diff --git a/packages/worker/src/api/controllers/global/email.js b/packages/worker/src/api/controllers/global/email.js index 50e7acdb1a..57b78a6d7a 100644 --- a/packages/worker/src/api/controllers/global/email.js +++ b/packages/worker/src/api/controllers/global/email.js @@ -2,15 +2,8 @@ const { sendEmail } = require("../../../utilities/email") const { getGlobalDB } = require("@budibase/auth/tenancy") exports.sendEmail = async ctx => { - let { - workspaceId, - email, - userId, - purpose, - contents, - from, - subject, - } = ctx.request.body + let { workspaceId, email, userId, purpose, contents, from, subject } = + ctx.request.body let user if (userId) { const db = getGlobalDB() diff --git a/packages/worker/src/api/controllers/global/users.js b/packages/worker/src/api/controllers/global/users.js index 3153328ace..e2284b09a8 100644 --- a/packages/worker/src/api/controllers/global/users.js +++ b/packages/worker/src/api/controllers/global/users.js @@ -330,13 +330,16 @@ exports.inviteAccept = async ctx => { try { // info is an extension of the user object that was stored by global const { email, info } = await checkInviteCode(inviteCode) - ctx.body = await saveUser({ - firstName, - lastName, - password, - email, - ...info, - }, info.tenantId) + ctx.body = await saveUser( + { + firstName, + lastName, + password, + email, + ...info, + }, + info.tenantId + ) // this will flesh out the body response await exports.save(ctx) } catch (err) { diff --git a/packages/worker/src/api/controllers/global/workspaces.js b/packages/worker/src/api/controllers/global/workspaces.js index fb1a859826..95a1ec296d 100644 --- a/packages/worker/src/api/controllers/global/workspaces.js +++ b/packages/worker/src/api/controllers/global/workspaces.js @@ -1,7 +1,4 @@ -const { - getWorkspaceParams, - generateWorkspaceID, -} = require("@budibase/auth/db") +const { getWorkspaceParams, generateWorkspaceID } = require("@budibase/auth/db") const { getGlobalDB } = require("@budibase/auth/tenancy") exports.save = async function (ctx) { diff --git a/packages/worker/src/api/index.js b/packages/worker/src/api/index.js index d39546ff3a..1e2a12ab1b 100644 --- a/packages/worker/src/api/index.js +++ b/packages/worker/src/api/index.js @@ -2,7 +2,8 @@ const Router = require("@koa/router") const compress = require("koa-compress") const zlib = require("zlib") const { routes } = require("./routes") -const { buildAuthMiddleware, auditLog, buildTenancyMiddleware } = require("@budibase/auth").auth +const { buildAuthMiddleware, auditLog, buildTenancyMiddleware } = + require("@budibase/auth").auth const NO_TENANCY_ENDPOINTS = [ { @@ -12,7 +13,7 @@ const NO_TENANCY_ENDPOINTS = [ { route: "/api/global/users/self", method: "GET", - } + }, ] const PUBLIC_ENDPOINTS = [ diff --git a/packages/worker/src/constants/templates/index.js b/packages/worker/src/constants/templates/index.js index 44fe345af1..ac5427ba1f 100644 --- a/packages/worker/src/constants/templates/index.js +++ b/packages/worker/src/constants/templates/index.js @@ -6,9 +6,7 @@ const { GLOBAL_OWNER, } = require("../index") const { join } = require("path") -const { - getTemplateParams, -} = require("@budibase/auth/db") +const { getTemplateParams } = require("@budibase/auth/db") const { getGlobalDB } = require("@budibase/auth/tenancy") exports.EmailTemplates = { diff --git a/packages/worker/src/utilities/email.js b/packages/worker/src/utilities/email.js index 22de6b4d6d..c32ff05cf5 100644 --- a/packages/worker/src/utilities/email.js +++ b/packages/worker/src/utilities/email.js @@ -68,12 +68,7 @@ async function getLinkCode(purpose, email, user, info = null) { * @param {string|null} contents if using a custom template can supply contents for context. * @return {Promise} returns the built email HTML if all provided parameters were valid. */ -async function buildEmail( - purpose, - email, - context, - { user, contents } = {} -) { +async function buildEmail(purpose, email, context, { user, contents } = {}) { // this isn't a full email if (FULL_EMAIL_PURPOSES.indexOf(purpose) === -1) { throw `Unable to build an email of type ${purpose}` diff --git a/packages/worker/src/utilities/templates.js b/packages/worker/src/utilities/templates.js index 31d92e9226..4dee52b531 100644 --- a/packages/worker/src/utilities/templates.js +++ b/packages/worker/src/utilities/templates.js @@ -44,9 +44,7 @@ exports.getSettingsTemplateContext = async (purpose, code = null) => { case EmailTemplatePurpose.INVITATION: context[InternalTemplateBindings.INVITE_CODE] = code context[InternalTemplateBindings.INVITE_URL] = checkSlashesInUrl( - addTenantToUrl( - `${URL}/builder/invite?code=${code}` - ) + addTenantToUrl(`${URL}/builder/invite?code=${code}`) ) break }