Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
app: add health check (#2713)
Thibault Le Ouay90cd8efda1d6
diff --git a/apps/dashboard/next-env.d.ts b/apps/dashboard/next-env.d.tsindex a419cbe4e..ce4e94a6b 100644--- a/apps/dashboard/next-env.d.ts+++ b/apps/dashboard/next-env.d.ts@@ -1,7 +1,7 @@/// <reference types="next" />/// <reference types="next/image-types/global" />-import "./.next/dev/types/routes.d.ts";-import "./.next/dev/types/root-params.d.ts";+import "./.next/types/routes.d.ts";+import "./.next/types/root-params.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.diff --git a/apps/dashboard/package.json b/apps/dashboard/package.jsonindex 0e34ce68f..c5584b86e 100644--- a/apps/dashboard/package.json+++ b/apps/dashboard/package.json@@ -32,6 +32,10 @@"@openstatus/emails": "workspace:*","@openstatus/error": "workspace:*","@openstatus/header-analysis": "workspace:*",+ "@openstatus/health": "catalog:",+ "@openstatus/health-tinybird": "catalog:",+ "@openstatus/health-turso": "catalog:",+ "@openstatus/health-upstash": "catalog:","@openstatus/icons": "workspace:*","@openstatus/importers": "workspace:*","@openstatus/locales": "workspace:*",diff --git a/apps/dashboard/src/app/api/health/route.ts b/apps/dashboard/src/app/api/health/route.tsnew file mode 100644index 000000000..e8efaad20--- /dev/null+++ b/apps/dashboard/src/app/api/health/route.ts@@ -0,0 +1,35 @@+import { db } from "@openstatus/db";+import { createHealthHandler } from "@openstatus/health";+import { tinybirdProbe } from "@openstatus/health-tinybird";+import { tursoProbe } from "@openstatus/health-turso";+import { upstashProbe } from "@openstatus/health-upstash";+import { TINYBIRD_DEFAULT_URL, isTinybirdNoop } from "@openstatus/tinybird";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";++const handler = createHealthHandler({+ deadlineMs: 4_000,+ probes: [+ tursoProbe({ client: db.$client }),+ tinybirdProbe({+ baseUrl: process.env.TINYBIRD_URL || TINYBIRD_DEFAULT_URL,+ skip: () =>+ !process.env.TINY_BIRD_API_KEY ||+ isTinybirdNoop(process.env.TINYBIRD_NOOP),+ }),+ // Probe factories reject an empty url at construction; a local `.env`+ // leaves Upstash blank.+ ...(process.env.UPSTASH_REDIS_REST_URL+ ? [+ upstashProbe({+ url: process.env.UPSTASH_REDIS_REST_URL,+ token: process.env.UPSTASH_REDIS_REST_TOKEN ?? "",+ }),+ ]+ : []),+ ],+});++export const GET = handler;+export const HEAD = handler;diff --git a/apps/status-page/package.json b/apps/status-page/package.jsonindex 1a6588abf..21a2755c4 100644--- a/apps/status-page/package.json+++ b/apps/status-page/package.json@@ -29,6 +29,10 @@"@openstatus/db": "workspace:*","@openstatus/emails": "workspace:*","@openstatus/error": "workspace:*",+ "@openstatus/health": "catalog:",+ "@openstatus/health-tinybird": "catalog:",+ "@openstatus/health-turso": "catalog:",+ "@openstatus/health-upstash": "catalog:","@openstatus/icons": "workspace:*","@openstatus/locales": "workspace:*","@openstatus/react": "workspace:*",diff --git a/apps/status-page/src/app/api/health/route.ts b/apps/status-page/src/app/api/health/route.tsnew file mode 100644index 000000000..e8efaad20--- /dev/null+++ b/apps/status-page/src/app/api/health/route.ts@@ -0,0 +1,35 @@+import { db } from "@openstatus/db";+import { createHealthHandler } from "@openstatus/health";+import { tinybirdProbe } from "@openstatus/health-tinybird";+import { tursoProbe } from "@openstatus/health-turso";+import { upstashProbe } from "@openstatus/health-upstash";+import { TINYBIRD_DEFAULT_URL, isTinybirdNoop } from "@openstatus/tinybird";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";++const handler = createHealthHandler({+ deadlineMs: 4_000,+ probes: [+ tursoProbe({ client: db.$client }),+ tinybirdProbe({+ baseUrl: process.env.TINYBIRD_URL || TINYBIRD_DEFAULT_URL,+ skip: () =>+ !process.env.TINY_BIRD_API_KEY ||+ isTinybirdNoop(process.env.TINYBIRD_NOOP),+ }),+ // Probe factories reject an empty url at construction; a local `.env`+ // leaves Upstash blank.+ ...(process.env.UPSTASH_REDIS_REST_URL+ ? [+ upstashProbe({+ url: process.env.UPSTASH_REDIS_REST_URL,+ token: process.env.UPSTASH_REDIS_REST_TOKEN ?? "",+ }),+ ]+ : []),+ ],+});++export const GET = handler;+export const HEAD = handler;diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 0d1fded8a..32b6456a3 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -745,6 +745,18 @@ importers:'@openstatus/header-analysis':specifier: workspace:*version: link:../../packages/header-analysis+ '@openstatus/health':+ specifier: 'catalog:'+ version: 0.1.0+ '@openstatus/health-tinybird':+ specifier: 'catalog:'+ version: 0.1.0(@openstatus/[email protected])+ '@openstatus/health-turso':+ specifier: 'catalog:'+ version: 0.1.0(@libsql/[email protected])(@openstatus/[email protected])+ '@openstatus/health-upstash':+ specifier: 'catalog:'+ version: 0.1.0(@openstatus/[email protected])'@openstatus/icons':specifier: workspace:*version: link:../../packages/icons@@ -1279,6 +1291,18 @@ importers:'@openstatus/error':specifier: workspace:*version: link:../../packages/error+ '@openstatus/health':+ specifier: 'catalog:'+ version: 0.1.0+ '@openstatus/health-tinybird':+ specifier: 'catalog:'+ version: 0.1.0(@openstatus/[email protected])+ '@openstatus/health-turso':+ specifier: 'catalog:'+ version: 0.1.0(@libsql/[email protected])(@openstatus/[email protected])+ '@openstatus/health-upstash':+ specifier: 'catalog:'+ version: 0.1.0(@openstatus/[email protected])'@openstatus/icons':specifier: workspace:*version: link:../../packages/icons