Some checks failed
Build and publish / build (push) Failing after 19s
Source moved verbatim from mp/shop/ on 2026-04-29; mp was the first concrete adapter consuming the libreshop toolkit. Builds and publishes git.librete.ch/libreshop/shop on every main / v* push via the standard .gitea/workflows/build.yml shared across libreshop components.
27 lines
815 B
TypeScript
27 lines
815 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const config = useRuntimeConfig();
|
|
const healthStatus: Record<string, unknown> = { status: "ok" };
|
|
|
|
// Check CMS connectivity (CMS returns 204 No Content for /_health)
|
|
try {
|
|
const cmsUrl = config.cmsInternalUrl || "http://cms:5555";
|
|
await $fetch(`${cmsUrl}/_health`, {
|
|
timeout: 5000,
|
|
ignoreResponseError: false
|
|
});
|
|
// If we get here without error, CMS is responding (even with 204)
|
|
healthStatus.cms_responding = true;
|
|
} catch (error) {
|
|
healthStatus.cms_responding = false;
|
|
healthStatus.status = "degraded";
|
|
}
|
|
|
|
// Check if API token is configured
|
|
healthStatus.api_token_configured = !!config.shopApiToken;
|
|
|
|
const statusCode = healthStatus.status === "ok" ? 200 : 503;
|
|
setResponseStatus(event, statusCode);
|
|
|
|
return healthStatus;
|
|
});
|