Files
mintel.me/apps/web/app/api/health/cms/route.ts
Marc Mintel 905ce98bc4
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Failing after 54s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
chore: align deployment pipeline with klz-2026 standards
- Add branch deployment support

- Switch build platform to linux/amd64

- Extract checks to turbo pipeline

- Add pre/post-deploy scripts & cms-sync
2026-03-01 00:41:38 +01:00

43 lines
1.3 KiB
TypeScript

import { NextResponse } from "next/server";
import { getPayload } from "payload";
import configPromise from "@payload-config";
export const dynamic = "force-dynamic";
/**
* Deep CMS Health Check
* Validates that Payload CMS can actually query the database.
* Used by post-deploy smoke tests to catch migration/schema issues.
*/
export async function GET() {
const checks: Record<string, string> = {};
try {
const payload = await getPayload({ config: configPromise });
checks.init = "ok";
// Verify each collection can be queried (catches missing locale tables, broken migrations)
// Adjusted for mintel.me collections
const collections = ["posts", "projects", "media", "inquiries"] as const;
for (const collection of collections) {
try {
await payload.find({ collection, limit: 1 });
checks[collection] = "ok";
} catch (e: any) {
checks[collection] = `error: ${e.message?.substring(0, 100)}`;
}
}
const hasErrors = Object.values(checks).some((v) => v.startsWith("error"));
return NextResponse.json(
{ status: hasErrors ? "degraded" : "ok", checks },
{ status: hasErrors ? 503 : 200 },
);
} catch (e: any) {
return NextResponse.json(
{ status: "error", message: e.message?.substring(0, 200), checks },
{ status: 503 },
);
}
}