diff --git a/packages/server/src/api/controllers/rowAction/run.ts b/packages/server/src/api/controllers/rowAction/run.ts index 06c4b36f86..a1fa0cfe69 100644 --- a/packages/server/src/api/controllers/rowAction/run.ts +++ b/packages/server/src/api/controllers/rowAction/run.ts @@ -1,3 +1,14 @@ -export function run() { - throw new Error("Function not implemented.") +import { RowActionTriggerRequest, Ctx } from "@budibase/types" +import sdk from "../../../sdk" + +export async function run(ctx: Ctx) { + const { tableId } = ctx.params + const table = await sdk.tables.getTable(tableId) + if (!table) { + ctx.throw(404) + } + + const { rowId } = ctx.request.body + console.warn({ rowId }) + ctx.status = 200 } diff --git a/packages/server/src/api/routes/rowAction.ts b/packages/server/src/api/routes/rowAction.ts index f4f20822d1..709a1c7c1c 100644 --- a/packages/server/src/api/routes/rowAction.ts +++ b/packages/server/src/api/routes/rowAction.ts @@ -1,9 +1,13 @@ import Router from "@koa/router" +import Joi from "joi" +import { middleware, permissions } from "@budibase/backend-core" import * as rowActionController from "../controllers/rowAction" import { authorizedResource } from "../../middleware/authorized" -import { middleware, permissions } from "@budibase/backend-core" -import Joi from "joi" +import { + middleware as appInfoMiddleware, + AppType, +} from "../../middleware/appInfo" const { PermissionLevel, PermissionType } = permissions @@ -45,7 +49,8 @@ router // Other endpoints .post( - "/api/tables/:tableId/actions/:actionId/run", + "/api/tables/:tableId/actions/:actionId/trigger", + appInfoMiddleware({ appType: AppType.PROD }), authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), rowActionController.run )