diff --git a/packages/server/src/api/controllers/ops.ts b/packages/server/src/api/controllers/ops.ts index 89ad0ac97b..dc331bb3a3 100644 --- a/packages/server/src/api/controllers/ops.ts +++ b/packages/server/src/api/controllers/ops.ts @@ -1,16 +1,7 @@ -import { Ctx } from "@budibase/types" +import { Ctx, LogOpsRequest, ErrorOpsRequest } from "@budibase/types" import { logging } from "@budibase/backend-core" -interface LogRequest { - message: string - data?: any -} - -interface ErrorRequest { - message: string -} - -export async function log(ctx: Ctx) { +export async function log(ctx: Ctx) { const body = ctx.request.body console.trace(body.message, body.data) console.debug(body.message, body.data) @@ -20,13 +11,13 @@ export async function log(ctx: Ctx) { ctx.status = 204 } -export async function alert(ctx: Ctx) { +export async function alert(ctx: Ctx) { const body = ctx.request.body logging.logAlert(body.message, new Error(body.message)) ctx.status = 204 } -export async function error(ctx: Ctx) { +export async function error(ctx: Ctx) { const body = ctx.request.body throw new Error(body.message) } diff --git a/packages/types/src/api/web/system/index.ts b/packages/types/src/api/web/system/index.ts index 8820bf5cd1..0ce2738ddb 100644 --- a/packages/types/src/api/web/system/index.ts +++ b/packages/types/src/api/web/system/index.ts @@ -1,2 +1,3 @@ export * from "./environment" export * from "./status" +export * from "./ops" diff --git a/packages/types/src/api/web/system/ops.ts b/packages/types/src/api/web/system/ops.ts new file mode 100644 index 0000000000..390e4db006 --- /dev/null +++ b/packages/types/src/api/web/system/ops.ts @@ -0,0 +1,8 @@ +export interface LogOpsRequest { + message: string + data?: any +} + +export interface ErrorOpsRequest { + message: string +}