Skip to content

Commit a8d11e0

Browse files
committed
Update ENSApi health check logic to include ability to build EnsApiPulicClient object
1 parent eb329fc commit a8d11e0

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

apps/ensapi/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { errorResponse } from "@/lib/handlers/error-response";
1515
import { factory } from "@/lib/hono-factory";
1616
import { sdk } from "@/lib/instrumentation";
1717
import logger from "@/lib/logger";
18+
import { publicConfigBuilder } from "@/lib/public-config-builder/singleton";
1819
import { indexingStatusMiddleware } from "@/middleware/indexing-status.middleware";
1920
import { generateOpenApi31Document } from "@/openapi-document";
2021

@@ -84,7 +85,17 @@ app.get("/openapi.json", (c) => {
8485

8586
// will automatically 503 if config is not available due to ensIndexerPublicConfigMiddleware
8687
app.get("/health", async (c) => {
87-
return c.json({ message: "fallback ok" });
88+
try {
89+
// ENSApi is healthy when its Public Config can be successfully built.
90+
await publicConfigBuilder.getPublicConfig();
91+
92+
return c.json({ message: "fallback ok" });
93+
} catch (error) {
94+
logger.error(error, "Health check failed: unable to get ENSApi Public Config");
95+
96+
// Report unhealthy status
97+
return errorResponse(c, "Service Unavailable", 503);
98+
}
8899
});
89100

90101
// log hono errors to console

0 commit comments

Comments
 (0)