makearmy-app/app/api/health/options/route.ts

28 lines
1.2 KiB
TypeScript

// app/api/health/options/route.ts
import { NextResponse } from "next/server";
import { directusFetch } from "@/lib/directus";
const TESTS = [
{ name: "material", path: "/items/material?limit=1" },
{ name: "material_coating", path: "/items/material_coating?limit=1" },
{ name: "material_color", path: "/items/material_color?limit=1" },
{ name: "material_opacity", path: "/items/material_opacity?limit=1" },
{ name: "laser_software", path: "/items/laser_software?limit=1" },
{ name: "laser_source", path: "/items/laser_source?limit=1" },
{ name: "laser_scan_lens", path: "/items/laser_scan_lens?limit=1" },
{ name: "laser_focusing_lens",path: "/items/laser_focusing_lens?limit=1" },
];
export async function GET() {
const results: any[] = [];
for (const t of TESTS) {
try {
const { data } = await directusFetch<{ data: any[] }>(t.path);
const first = data?.[0] ?? null;
results.push({ name: t.name, ok: true, sample_id: first?.submission_id ?? first?.id ?? null });
} catch (e: any) {
results.push({ name: t.name, ok: false, error: e?.message || String(e) });
}
}
return NextResponse.json({ ok: true, results });
}