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.
643 B Β· 23 lines
TypeScript
123456789101112131415161718192021222324import { and, eq } from "@openstatus/db";import { incidentTable } from "@openstatus/db/src/schema";
import type { DB } from "../context";import { NotFoundError } from "../errors";
/** Load an incident by id, scoped to the workspace. Throws on miss. */export async function getIncidentInWorkspace(args: { tx: DB; id: number; workspaceId: number;}) { const { tx, id, workspaceId } = args; const row = await tx .select() .from(incidentTable) .where( and(eq(incidentTable.id, id), eq(incidentTable.workspaceId, workspaceId)), ) .get(); if (!row) throw new NotFoundError("incident", id); return row;}