1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00
budibase/packages/server/src/api/routes/webhook.ts

28 lines
826 B
TypeScript

import Router from "@koa/router"
import * as controller from "../controllers/webhook"
import authorized from "../../middleware/authorized"
import { permissions } from "@budibase/backend-core"
import { webhookValidator } from "./utils/validators"
const BUILDER = permissions.BUILDER
const router = new Router()
router
.get("/api/webhooks", authorized(BUILDER), controller.fetch)
.put(
"/api/webhooks",
authorized(BUILDER),
webhookValidator(),
controller.save
)
.delete("/api/webhooks/:id/:rev", authorized(BUILDER), controller.destroy)
.post(
"/api/webhooks/schema/:instance/:id",
authorized(BUILDER),
controller.buildSchema
)
// this shouldn't have authorisation, right now its always public
.post("/api/webhooks/trigger/:instance/:id", controller.trigger)
export default router