From 107bd08e21dfefa5f6f82cb1a7ab41778a727a21 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Jul 2024 10:46:15 +0200 Subject: [PATCH] Endpoint scaffolding --- .../src/api/controllers/rowAction/crud.ts | 15 +++++++ .../src/api/controllers/rowAction/index.ts | 2 + .../src/api/controllers/rowAction/run.ts | 3 ++ packages/server/src/api/routes/rowAction.ts | 41 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 packages/server/src/api/controllers/rowAction/crud.ts create mode 100644 packages/server/src/api/controllers/rowAction/index.ts create mode 100644 packages/server/src/api/controllers/rowAction/run.ts create mode 100644 packages/server/src/api/routes/rowAction.ts diff --git a/packages/server/src/api/controllers/rowAction/crud.ts b/packages/server/src/api/controllers/rowAction/crud.ts new file mode 100644 index 0000000000..3bea2de73c --- /dev/null +++ b/packages/server/src/api/controllers/rowAction/crud.ts @@ -0,0 +1,15 @@ +export function find() { + throw new Error("Function not implemented.") +} + +export function create() { + throw new Error("Function not implemented.") +} + +export function update() { + throw new Error("Function not implemented.") +} + +export function remove() { + throw new Error("Function not implemented.") +} diff --git a/packages/server/src/api/controllers/rowAction/index.ts b/packages/server/src/api/controllers/rowAction/index.ts new file mode 100644 index 0000000000..bf65119f1a --- /dev/null +++ b/packages/server/src/api/controllers/rowAction/index.ts @@ -0,0 +1,2 @@ +export * from "./crud" +export * from "./run" diff --git a/packages/server/src/api/controllers/rowAction/run.ts b/packages/server/src/api/controllers/rowAction/run.ts new file mode 100644 index 0000000000..06c4b36f86 --- /dev/null +++ b/packages/server/src/api/controllers/rowAction/run.ts @@ -0,0 +1,3 @@ +export function run() { + throw new Error("Function not implemented.") +} diff --git a/packages/server/src/api/routes/rowAction.ts b/packages/server/src/api/routes/rowAction.ts new file mode 100644 index 0000000000..7bc50377b8 --- /dev/null +++ b/packages/server/src/api/routes/rowAction.ts @@ -0,0 +1,41 @@ +import Router from "@koa/router" +import * as rowActionController from "../controllers/rowAction" +import { authorizedResource } from "../../middleware/authorized" + +import { permissions } from "@budibase/backend-core" + +const { PermissionLevel, PermissionType } = permissions + +const router: Router = new Router() + +// CRUD endpoints +router + .get( + "/api/tables/:tableId/actions", + authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), + rowActionController.find + ) + .post( + "/api/tables/:tableId/actions", + authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), + rowActionController.create + ) + .put( + "/api/tables/:tableId/actions/:actionId", + authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), + rowActionController.update + ) + .delete( + "/api/tables/:tableId/actions/:actionId", + authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), + rowActionController.remove + ) + + // Other endpoints + .post( + "/api/tables/:tableId/actions/:actionId/run", + authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"), + rowActionController.run + ) + +export default router