From 3aeb6653c6920d706aa530e01357f5602d5c5c51 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 28 Nov 2022 18:14:10 +0000 Subject: [PATCH] Some fixes after re-running server tests. --- packages/server/src/api/controllers/public/rows.ts | 2 +- packages/server/src/api/controllers/public/utils.ts | 4 ++-- packages/server/src/api/routes/public/index.ts | 9 +++------ packages/server/src/automations/steps/utils.ts | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/server/src/api/controllers/public/rows.ts b/packages/server/src/api/controllers/public/rows.ts index 67059ec2f5..df856f1fe0 100644 --- a/packages/server/src/api/controllers/public/rows.ts +++ b/packages/server/src/api/controllers/public/rows.ts @@ -1,6 +1,6 @@ import * as rowController from "../row" import { addRev } from "./utils" -import { Row } from "../../../definitions/common" +import { Row } from "@budibase/types" import { convertBookmark } from "../../../utilities" // makes sure that the user doesn't need to pass in the type, tableId or _id params for diff --git a/packages/server/src/api/controllers/public/utils.ts b/packages/server/src/api/controllers/public/utils.ts index 6909db9628..a51b6b5fff 100644 --- a/packages/server/src/api/controllers/public/utils.ts +++ b/packages/server/src/api/controllers/public/utils.ts @@ -1,4 +1,4 @@ -const { getAppDB } = require("@budibase/backend-core/context") +import { context } from "@budibase/backend-core" import { isExternalTable } from "../../../integrations/utils" import { APP_PREFIX, DocumentType } from "../../../db/utils" @@ -13,7 +13,7 @@ export async function addRev( if (body._id.startsWith(APP_PREFIX)) { id = DocumentType.APP_METADATA } - const db = getAppDB() + const db = context.getAppDB() const dbDoc = await db.get(id) body._rev = dbDoc._rev // update ID in case it is an app ID diff --git a/packages/server/src/api/routes/public/index.ts b/packages/server/src/api/routes/public/index.ts index 198ba2d2b2..79e7731752 100644 --- a/packages/server/src/api/routes/public/index.ts +++ b/packages/server/src/api/routes/public/index.ts @@ -12,11 +12,8 @@ import env from "../../../environment" // below imports don't have declaration files const Router = require("@koa/router") const { RateLimit, Stores } = require("koa2-ratelimit") -const { - PermissionLevel, - PermissionType, -} = require("@budibase/backend-core/permissions") -const { getRedisOptions } = require("@budibase/backend-core/redis").utils +import { redis, permissions } from "@budibase/backend-core" +const { PermissionType, PermissionLevel } = permissions const PREFIX = "/api/public/v1" // allow a lot more requests when in test @@ -31,7 +28,7 @@ function getApiLimitPerSecond(): number { let rateLimitStore: any = null if (!env.isTest()) { - const REDIS_OPTS = getRedisOptions() + const REDIS_OPTS = redis.utils.getRedisOptions() let options if (REDIS_OPTS.redisProtocolUrl) { // fully qualified redis URL diff --git a/packages/server/src/automations/steps/utils.ts b/packages/server/src/automations/steps/utils.ts index 02b0f4d34c..8b99044303 100644 --- a/packages/server/src/automations/steps/utils.ts +++ b/packages/server/src/automations/steps/utils.ts @@ -20,7 +20,7 @@ export async function getFetchResponse(fetched: any) { // throw added to them, so that controllers don't // throw a ctx.throw undefined when error occurs // opts can contain, body, params and version -export async function buildCtx( +export function buildCtx( appId: string, emitter?: EventEmitter | null, opts: any = {}