Adding an API for publishing an event from the frontend.
This commit is contained in:
parent
5a2937c8d2
commit
557a9a8eeb
|
@ -0,0 +1,7 @@
|
||||||
|
export enum EventPublishType {
|
||||||
|
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable_upgrade_panel_opened",
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PostEventPublishRequest {
|
||||||
|
type: EventPublishType
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
export * from "./environmentVariables"
|
export * from "./environmentVariables"
|
||||||
|
export * from "./events"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import {
|
||||||
|
UserCtx,
|
||||||
|
PostEventPublishRequest,
|
||||||
|
EventPublishType,
|
||||||
|
} from "@budibase/types"
|
||||||
|
import { events } from "@budibase/backend-core"
|
||||||
|
|
||||||
|
export async function publish(ctx: UserCtx<PostEventPublishRequest, void>) {
|
||||||
|
switch (ctx.request.body.type) {
|
||||||
|
case EventPublishType.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED:
|
||||||
|
await events.environmentVariable.upgradePanelOpened(ctx.user._id!)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
ctx.throw(400, "Invalid publish event type.")
|
||||||
|
}
|
||||||
|
ctx.status = 200
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import Router from "@koa/router"
|
||||||
|
import * as controller from "../../controllers/global/events"
|
||||||
|
|
||||||
|
const router: Router = new Router()
|
||||||
|
|
||||||
|
router.post("/api/global/event/publish", controller.publish)
|
||||||
|
|
||||||
|
export default router
|
Loading…
Reference in New Issue