1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

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