Skip to content

Commit 3f41b15

Browse files
Add health route and health page
Implemented a new /health endpoint page Health.tsx that reports basic deployment health status using env vars. Wired route into App.tsx to expose /health. Also ensured lazy loading and integration with existing app structure. X-Lovable-Edit-ID: edt-78081b69-817f-451f-81c4-5b70863538ab
2 parents 3bc12fd + 0461239 commit 3f41b15

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Checkout = lazy(() => import("./pages/Checkout"));
2424
const Profile = lazy(() => import("./pages/Profile"));
2525
const Contact = lazy(() => import("./pages/Contact"));
2626
const Shop = lazy(() => import("./pages/Shop"));
27+
const Health = lazy(() => import("./pages/Health"));
2728

2829
const queryClient = new QueryClient();
2930

@@ -71,6 +72,7 @@ function AppContent() {
7172
<Route path="/profile" element={<Profile />} />
7273
<Route path="/contact" element={<Contact />} />
7374
<Route path="/admin/enrichment" element={<AdminEnrichment />} />
75+
<Route path="/health" element={<Health />} />
7476
<Route path="*" element={<NotFound />} />
7577
</Routes>
7678
</Suspense>

src/pages/Health.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useEffect, useState } from "react";
2+
3+
interface HealthStatus {
4+
status: "ok" | "degraded";
5+
version: string;
6+
timestamp: string;
7+
checks: {
8+
supabase: boolean;
9+
shopify: boolean;
10+
};
11+
}
12+
13+
const Health = () => {
14+
const [health, setHealth] = useState<HealthStatus | null>(null);
15+
16+
useEffect(() => {
17+
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
18+
const shopifyDomain = import.meta.env.VITE_SHOPIFY_STORE_DOMAIN;
19+
20+
const checks = { supabase: !!supabaseUrl, shopify: !!shopifyDomain };
21+
22+
setHealth({
23+
status: checks.supabase ? "ok" : "degraded",
24+
version: "1.0.0",
25+
timestamp: new Date().toISOString(),
26+
checks,
27+
});
28+
}, []);
29+
30+
if (!health) return null;
31+
32+
return (
33+
<pre style={{ fontFamily: "monospace", padding: "2rem" }}>
34+
{JSON.stringify(health, null, 2)}
35+
</pre>
36+
);
37+
};
38+
39+
export default Health;

0 commit comments

Comments
 (0)