diff --git a/packages/frontend-core/src/api/events.js b/packages/frontend-core/src/api/events.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/types/src/api/web/global/events.ts b/packages/types/src/api/web/global/events.ts new file mode 100644 index 0000000000..907cfc74aa --- /dev/null +++ b/packages/types/src/api/web/global/events.ts @@ -0,0 +1,7 @@ +export enum EventPublishType { + ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable_upgrade_panel_opened", +} + +export interface PostEventPublishRequest { + type: EventPublishType +} diff --git a/packages/types/src/api/web/global/index.ts b/packages/types/src/api/web/global/index.ts index a99934c39c..415ed55ab1 100644 --- a/packages/types/src/api/web/global/index.ts +++ b/packages/types/src/api/web/global/index.ts @@ -1 +1,2 @@ export * from "./environmentVariables" +export * from "./events" diff --git a/packages/worker/src/api/controllers/global/events.ts b/packages/worker/src/api/controllers/global/events.ts new file mode 100644 index 0000000000..758fb41b54 --- /dev/null +++ b/packages/worker/src/api/controllers/global/events.ts @@ -0,0 +1,17 @@ +import { + UserCtx, + PostEventPublishRequest, + EventPublishType, +} from "@budibase/types" +import { events } from "@budibase/backend-core" + +export async function publish(ctx: UserCtx) { + 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 +} diff --git a/packages/worker/src/api/routes/global/events.ts b/packages/worker/src/api/routes/global/events.ts new file mode 100644 index 0000000000..6fe8088761 --- /dev/null +++ b/packages/worker/src/api/routes/global/events.ts @@ -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