From 3fbeff1121ffe1869a04722f98383ee0944256cf Mon Sep 17 00:00:00 2001 From: waterlemonnn Date: Mon, 10 Aug 2026 03:02:15 +0700 Subject: [PATCH] fix(registry): increase estimatedCostUsd cap to 1 Trillion Increases the max Zod schema limit for estimatedCostUsd from to . Also refactors the display logic to use the shared formatUsd utility, which correctly formats billion-dollar amounts. Adds build-time fallbacks for Resend. Closes #51 --- app/(public)/case/[caseNumber]/page.tsx | 10 ++-------- app/(public)/hall-of-fame/page.tsx | 10 ++-------- app/api/og/[caseNumber]/route.tsx | 9 ++------- components/post/PostCard.tsx | 11 +++-------- lib/resend/newsletter.ts | 2 +- lib/resend/send.ts | 2 +- lib/schemas/submit.ts | 2 +- package.json | 10 +++++++++- pnpm-workspace.yaml | 9 +++++++++ 9 files changed, 30 insertions(+), 35 deletions(-) create mode 100644 pnpm-workspace.yaml diff --git a/app/(public)/case/[caseNumber]/page.tsx b/app/(public)/case/[caseNumber]/page.tsx index ce16b4e..4189961 100644 --- a/app/(public)/case/[caseNumber]/page.tsx +++ b/app/(public)/case/[caseNumber]/page.tsx @@ -17,6 +17,7 @@ import { } from "@/lib/constants/severity"; import { getSiteUrl } from "@/lib/utils/urls"; import { incidentDate } from "@/lib/utils/incident-date"; +import { formatUsd } from "@/lib/utils/format"; export const revalidate = 60; @@ -94,14 +95,7 @@ export default async function CasePage({ params }: PageProps) { timeZone: "UTC", }).format(new Date(incidentDate(post))); - const cost = - post.estimatedCostUsd != null - ? post.estimatedCostUsd >= 1_000_000 - ? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M` - : post.estimatedCostUsd >= 1_000 - ? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k` - : `$${post.estimatedCostUsd}` - : null; + const cost = formatUsd(post.estimatedCostUsd); const siteUrl = getSiteUrl(); const sourceDomain = getSourceDomain(post.sourceUrl); diff --git a/app/(public)/hall-of-fame/page.tsx b/app/(public)/hall-of-fame/page.tsx index 4b71268..80d80f9 100644 --- a/app/(public)/hall-of-fame/page.tsx +++ b/app/(public)/hall-of-fame/page.tsx @@ -4,6 +4,7 @@ import { fetchFeedPosts } from "@/lib/db/posts"; import { VoteButtons } from "@/components/post/VoteButtons"; import { Pagination } from "@/components/ui/Pagination"; import { EmptyState } from "@/components/ui/EmptyState"; +import { formatUsd } from "@/lib/utils/format"; export const revalidate = 60; @@ -86,14 +87,7 @@ export default async function HallOfFamePage({ searchParams }: PageProps) { {posts.map((post, i) => { const rank = rankOffset + i; const isTop3 = rank < 3; - const cost = - post.estimatedCostUsd != null - ? post.estimatedCostUsd >= 1_000_000 - ? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M` - : post.estimatedCostUsd >= 1_000 - ? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k` - : `$${post.estimatedCostUsd}` - : null; + const cost = formatUsd(post.estimatedCostUsd); return (
  • = 1_000_000 - ? `$${(data.estimatedCostUsd / 1_000_000).toFixed(1)}M` - : data.estimatedCostUsd >= 1_000 - ? `$${(data.estimatedCostUsd / 1_000).toFixed(0)}k` - : `$${data.estimatedCostUsd}` - : null; + const costFormatted = formatUsd(data?.estimatedCostUsd); return new ImageResponse(
    = 1_000_000 - ? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M` - : post.estimatedCostUsd >= 1_000 - ? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k` - : `$${post.estimatedCostUsd}` - : null; + const cost = formatUsd(post.estimatedCostUsd); return (
    diff --git a/lib/resend/newsletter.ts b/lib/resend/newsletter.ts index 0a1a187..9d8d4ff 100644 --- a/lib/resend/newsletter.ts +++ b/lib/resend/newsletter.ts @@ -1,7 +1,7 @@ import { Resend } from "resend"; import { getSiteUrl } from "@/lib/utils/urls"; -const resend = new Resend(process.env.RESEND_API_KEY); +const resend = new Resend(process.env.RESEND_API_KEY || "re_dummy"); const FROM = process.env.RESEND_NEWSLETTER_FROM ?? "AgentPostmortem "; diff --git a/lib/resend/send.ts b/lib/resend/send.ts index 35f7c0e..b3d2476 100644 --- a/lib/resend/send.ts +++ b/lib/resend/send.ts @@ -2,7 +2,7 @@ import { Resend } from "resend"; import { EditTokenEmail } from "./templates/EditTokenEmail"; import { getSiteUrl } from "@/lib/utils/urls"; -const resend = new Resend(process.env.RESEND_API_KEY); +const resend = new Resend(process.env.RESEND_API_KEY || "re_dummy"); interface SendEditTokenEmailParams { to: string; diff --git a/lib/schemas/submit.ts b/lib/schemas/submit.ts index 270a6bf..40b7548 100644 --- a/lib/schemas/submit.ts +++ b/lib/schemas/submit.ts @@ -26,7 +26,7 @@ export const submitSchema = z.object({ damageLevel: z.number().int().min(1).max(5) as z.ZodType<1 | 2 | 3 | 4 | 5>, /** Approximate USD financial damage — 0 for reputational only */ - estimatedCostUsd: z.number().int().min(0).max(100_000_000).optional(), + estimatedCostUsd: z.number().int().min(0).max(1_000_000_000_000).optional(), /** Tags — at least one required */ tags: z diff --git a/package.json b/package.json index d93b0c2..d23d7fd 100644 --- a/package.json +++ b/package.json @@ -58,5 +58,13 @@ "firefox >= 90", "safari >= 15", "edge >= 91" - ] + ], + "pnpm": { + "approvedBuilds": [ + "esbuild", + "sharp", + "unrs-resolver", + "workerd" + ] + } } diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..563d3a4 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,9 @@ +allowBuilds: + '0': esbuild + '1': sharp + '2': unrs-resolver + '3': workerd + esbuild: set this to true or false + sharp: set this to true or false + unrs-resolver: set this to true or false + workerd: set this to true or false