Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.1 kB ยท 36 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637import { eq } from "@openstatus/db";import { monitorIncidentTable } from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";import { requireScope } from "../auth";import { type ServiceContext, withTransaction } from "../context";import { getMonitorIncidentInWorkspace } from "./internal";import { DeleteMonitorIncidentInput } from "./schemas";
export async function deleteMonitorIncident(args: { ctx: ServiceContext; input: DeleteMonitorIncidentInput;}): Promise<void> { const { ctx } = args; requireScope(ctx, "write"); const input = DeleteMonitorIncidentInput.parse(args.input);
await withTransaction(ctx, async (tx) => { const existing = await getMonitorIncidentInWorkspace({ tx, id: input.id, workspaceId: ctx.workspace.id, });
await tx .delete(monitorIncidentTable) .where(eq(monitorIncidentTable.id, existing.id));
await emitAudit(tx, ctx, { action: "monitor_incident.delete", entityType: "monitor_incident", entityId: existing.id, before: existing, }); });}