From 97f7629345af35f103a7572256c89e4da9070bc8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 31 Jul 2023 10:50:33 +0200 Subject: [PATCH] Renames --- packages/server/src/api/routes/row.ts | 6 +++--- .../src/middleware/{guardViewRowInfo.ts => noViewData.ts} | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) rename packages/server/src/middleware/{guardViewRowInfo.ts => noViewData.ts} (55%) diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index 179082d8de..25224623c6 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -4,7 +4,7 @@ import authorized from "../../middleware/authorized" import { paramResource, paramSubResource } from "../../middleware/resourceId" import { permissions } from "@budibase/backend-core" import { internalSearchValidator } from "./utils/validators" -import guardViewRowInfo from "../../middleware/guardViewRowInfo" +import noViewData from "../../middleware/noViewData" const { PermissionType, PermissionLevel } = permissions const router: Router = new Router() @@ -175,7 +175,7 @@ router "/api/:tableId/rows", paramResource("tableId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), - guardViewRowInfo(), + noViewData(), rowController.save ) /** @@ -190,7 +190,7 @@ router "/api/:tableId/rows", paramResource("tableId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), - guardViewRowInfo(), + noViewData(), rowController.patch ) /** diff --git a/packages/server/src/middleware/guardViewRowInfo.ts b/packages/server/src/middleware/noViewData.ts similarity index 55% rename from packages/server/src/middleware/guardViewRowInfo.ts rename to packages/server/src/middleware/noViewData.ts index 7a7413b760..5a2bb45012 100644 --- a/packages/server/src/middleware/guardViewRowInfo.ts +++ b/packages/server/src/middleware/noViewData.ts @@ -1,12 +1,9 @@ import { Ctx, Row } from "@budibase/types" -const checkNoViewData = async (ctx: Ctx) => { +export default () => async (ctx: Ctx, next: any) => { if (ctx.request.body._viewId) { ctx.throw(400, "Table row endpoints cannot contain view info") } -} -export default () => async (ctx: any, next: any) => { - await checkNoViewData(ctx) return next() }