返回 CodeWhale
route.ts
根目录 / web / app / api / facts / route.ts
1 import { NextResponse } from "next/server";
2 import { BUILD_FACTS, getFactsWithProvenance, type RepoFacts } from "@/lib/facts";
3
4 export const dynamic = "force-dynamic";
5 export const revalidate = 0;
6
7 function summary(facts: RepoFacts) {
8 return {
9 sourceRevision: facts.sourceRevision,
10 sourceCommittedAt: facts.sourceCommittedAt,
11 version: facts.version,
12 providerCount: facts.providers.length,
13 toolCount: facts.toolCount,
14 };
15 }
16
17 /** Public, credential-free source/deployment drift receipt. */
18 export async function GET() {
19 const resolution = await getFactsWithProvenance();
20 return NextResponse.json(
21 {
22 schemaVersion: 1,
23 deployed: summary(BUILD_FACTS),
24 resolved: {
25 ...summary(resolution.facts),
26 source: resolution.source,
27 reason: resolution.reason,
28 },
29 latestPublishedRelease: resolution.facts.latestPublishedRelease,
30 },
31 {
32 headers: {
33 "Cache-Control": "no-store",
34 },
35 },
36 );
37 }
38
38 lines TYPESCRIPT