34 라인
873 B
TypeScript
34 라인
873 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
type Health = {
|
|
status: string;
|
|
db: { connected: boolean; now?: string; version?: string };
|
|
};
|
|
|
|
export default function DbStatus() {
|
|
const [health, setHealth] = useState<Health | null>(null);
|
|
const [error, setError] = useState(false);
|
|
|
|
useEffect(() => {
|
|
fetch("/api/health")
|
|
.then((res) => res.json())
|
|
.then(setHealth)
|
|
.catch(() => setError(true));
|
|
}, []);
|
|
|
|
if (error)
|
|
return <span className="text-sm text-red-500">● API 응답 없음</span>;
|
|
if (!health)
|
|
return <span className="text-sm text-gray-400">● 확인 중…</span>;
|
|
|
|
return health.db.connected ? (
|
|
<span className="text-sm text-green-600 dark:text-green-400">
|
|
● DB 연결됨 (PostgreSQL)
|
|
</span>
|
|
) : (
|
|
<span className="text-sm text-red-500">● DB 연결 안 됨</span>
|
|
);
|
|
}
|