feat: add healthcheck
This commit is contained in:
20
src/routes/api/health.ts
Normal file
20
src/routes/api/health.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { createAPIFileRoute } from "@tanstack/start/api";
|
||||||
|
import { prisma } from "@/lib/server/db";
|
||||||
|
|
||||||
|
export const Route = createAPIFileRoute("/api/health")({
|
||||||
|
GET: async () => {
|
||||||
|
let dbStatus = "disconnected";
|
||||||
|
try {
|
||||||
|
await prisma.$queryRaw`SELECT 1`;
|
||||||
|
dbStatus = "connected";
|
||||||
|
} catch {
|
||||||
|
dbStatus = "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
status: "ok",
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
database: dbStatus,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user