Endpoint scaffolding

This commit is contained in:
Adria Navarro 2024-07-10 10:46:15 +02:00
parent 3f5161aaf7
commit 107bd08e21
4 changed files with 61 additions and 0 deletions

View File

@ -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.")
}

View File

@ -0,0 +1,2 @@
export * from "./crud"
export * from "./run"

View File

@ -0,0 +1,3 @@
export function run() {
throw new Error("Function not implemented.")
}

View File

@ -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