feat: extract shop from mp/shop — initial libreshop/shop
Some checks failed
Build and publish / build (push) Failing after 19s
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.
This commit is contained in:
26
server/api/health.get.ts
Normal file
26
server/api/health.get.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
});
|
||||
Reference in New Issue
Block a user