Add Health Check Path

This commit is contained in:
Kalle 2022-02-26 14:55:55 +02:00
parent 5c7eca32e5
commit f1cd12fceb

17
app/routes/healthz.ts Normal file
View File

@ -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 });
}
};