ironGym/webapp/src/app/api/health/route.ts

23 lines
576 B
TypeScript

import { NextResponse } from "next/server";
import dbConnect from "@/database/dbConnect";
export async function GET() {
try {
// Try to connect to the database
await dbConnect();
// Return a successful response
return NextResponse.json(
{ status: "ok", message: "Service is healthy" },
{ status: 200 }
);
} catch (error) {
console.error("Health check failed:", error);
// Return an error response
return NextResponse.json(
{ status: "error", message: "Service is unhealthy" },
{ status: 500 }
);
}
}