diff --git a/app/routes/healthz.ts b/app/routes/healthz.ts new file mode 100644 index 000000000..af28c6d3e --- /dev/null +++ b/app/routes/healthz.ts @@ -0,0 +1,17 @@ +import { LoaderFunction } from "remix"; +import { db } from "~/utils/db.server"; + +export const loader: LoaderFunction = async () => { + try { + const res = await db.$queryRaw`SELECT 1+1 as val;`; + const val = (res as { val: 2 }[])[0].val; + if (val !== 2) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(`val was: ${val}`); + } + return new Response(null, { status: 204 }); + } catch (e) { + console.error((e as Error).message); + return new Response(null, { status: 500 }); + } +};