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.
987 B ยท 34 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435import { eq } from "@openstatus/db";import { incidentTable } from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";import { requireScope } from "../auth";import { type ServiceContext, withTransaction } from "../context";import { getIncidentInWorkspace } from "./internal";import { DeleteIncidentInput } from "./schemas";
export async function deleteIncident(args: { ctx: ServiceContext; input: DeleteIncidentInput;}): Promise<void> { const { ctx } = args; requireScope(ctx, "write"); const input = DeleteIncidentInput.parse(args.input);
await withTransaction(ctx, async (tx) => { const existing = await getIncidentInWorkspace({ tx, id: input.id, workspaceId: ctx.workspace.id, });
await tx.delete(incidentTable).where(eq(incidentTable.id, existing.id));
await emitAudit(tx, ctx, { action: "incident.delete", entityType: "incident", entityId: existing.id, before: existing, }); });}