Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a deterministic verification core: clinical-trial claims checked against ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI recomputed in code, oracle-tested), code-enforced exact-span grounding, and multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing at scale (unpdf + Docling), agentic workflows, Claude Science connector, compliance/audit, billing, public API, and more. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { NextRequest } from "next/server";
|
|
import { getPool } from "@/lib/db";
|
|
import { withOrg, type Ctx } from "@/lib/api/handler";
|
|
import { ok, fail } from "@/lib/api/response";
|
|
import { requireRole } from "@/lib/authz/rbac";
|
|
import { markRead, type Notification } from "@/lib/notify";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
const UUID_RE =
|
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
// POST /api/notifications/[id]/read — mark one of the current user's own
|
|
// notifications read. Org- and user-scoped: a member can only mark their own.
|
|
// This is a personal, low-stakes action, so no audit entry is written.
|
|
export const POST = withOrg(
|
|
async (_req: NextRequest, ctx: Ctx, params) => {
|
|
try {
|
|
requireRole(ctx, "viewer");
|
|
const id = params?.id;
|
|
if (!id || !UUID_RE.test(id)) {
|
|
return fail("Invalid notification id.", 400);
|
|
}
|
|
|
|
const updated = await markRead(
|
|
getPool(),
|
|
ctx.org.id,
|
|
ctx.user.id,
|
|
id
|
|
);
|
|
if (!updated) {
|
|
return fail("Notification not found.", 404);
|
|
}
|
|
return ok<Notification>(updated);
|
|
} catch (err) {
|
|
if (err instanceof Error && "status" in err) {
|
|
return fail(err.message, (err as { status: number }).status);
|
|
}
|
|
return fail("Failed to mark notification read.", 500);
|
|
}
|
|
}
|
|
);
|