Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

build: simplify health check routes

Brad Barbin94d4200d9cb6
diff --git a/apps/erp/app/routes/_public+/health.tsx b/apps/erp/app/routes/_public+/health.tsx
index 2bd9ba1284..b42e5f0bfe 100644
--- a/apps/erp/app/routes/_public+/health.tsx
+++ b/apps/erp/app/routes/_public+/health.tsx
@@ -1,49 +1,15 @@
-import { getCarbonServiceRole } from "@carbon/auth";
-
-// Simple health check that doesn't depend on database
export async function loader() {
- try {
- // Basic application health check
- const startTime = Date.now();
-
- // Optional: Add a lightweight database check with timeout
- const client = getCarbonServiceRole();
- const timeoutPromise = new Promise((_, reject) =>
- setTimeout(() => reject(new Error("Health check timeout")), 5000)
- );
-
- const healthCheck = client
- .from("attributeDataType")
- .select("id")
- .limit(1)
- .single();
-
- await Promise.race([healthCheck, timeoutPromise]);
-
- const responseTime = Date.now() - startTime;
-
- return new Response(
- JSON.stringify({
- status: "OK",
- timestamp: new Date().toISOString(),
- responseTime: `${responseTime}ms`,
- }),
- {
- headers: { "Content-Type": "application/json" },
- }
- );
- } catch (error: unknown) {
- console.log("health ❌", { error });
- return new Response(
- JSON.stringify({
- status: "ERROR",
- error: error instanceof Error ? error.message : "Unknown error",
- timestamp: new Date().toISOString(),
- }),
- {
- status: 500,
- headers: { "Content-Type": "application/json" },
- }
- );
- }
+ return new Response(
+ JSON.stringify({
+ status: "ok",
+ timestamp: new Date().toISOString(),
+ }),
+ {
+ status: 200,
+ headers: {
+ "Content-Type": "application/json",
+ "Cache-Control": "no-cache, no-store, must-revalidate",
+ },
+ }
+ );
}
diff --git a/apps/mes/app/routes/_public+/health.tsx b/apps/mes/app/routes/_public+/health.tsx
index 2bd9ba1284..b42e5f0bfe 100644
--- a/apps/mes/app/routes/_public+/health.tsx
+++ b/apps/mes/app/routes/_public+/health.tsx
@@ -1,49 +1,15 @@
-import { getCarbonServiceRole } from "@carbon/auth";
-
-// Simple health check that doesn't depend on database
export async function loader() {
- try {
- // Basic application health check
- const startTime = Date.now();
-
- // Optional: Add a lightweight database check with timeout
- const client = getCarbonServiceRole();
- const timeoutPromise = new Promise((_, reject) =>
- setTimeout(() => reject(new Error("Health check timeout")), 5000)
- );
-
- const healthCheck = client
- .from("attributeDataType")
- .select("id")
- .limit(1)
- .single();
-
- await Promise.race([healthCheck, timeoutPromise]);
-
- const responseTime = Date.now() - startTime;
-
- return new Response(
- JSON.stringify({
- status: "OK",
- timestamp: new Date().toISOString(),
- responseTime: `${responseTime}ms`,
- }),
- {
- headers: { "Content-Type": "application/json" },
- }
- );
- } catch (error: unknown) {
- console.log("health ❌", { error });
- return new Response(
- JSON.stringify({
- status: "ERROR",
- error: error instanceof Error ? error.message : "Unknown error",
- timestamp: new Date().toISOString(),
- }),
- {
- status: 500,
- headers: { "Content-Type": "application/json" },
- }
- );
- }
+ return new Response(
+ JSON.stringify({
+ status: "ok",
+ timestamp: new Date().toISOString(),
+ }),
+ {
+ status: 200,
+ headers: {
+ "Content-Type": "application/json",
+ "Cache-Control": "no-cache, no-store, must-revalidate",
+ },
+ }
+ );
}