30 lines
881 B
TypeScript
30 lines
881 B
TypeScript
import { FastifyInstance } from "fastify";
|
|
import { getBuildInfo } from "../utils/buildInfo";
|
|
|
|
export default async function routes(server: FastifyInstance) {
|
|
server.get("/health", async (_request, reply) => {
|
|
reply.header("Cache-Control", "no-store");
|
|
try {
|
|
await server.db.execute("SELECT 1");
|
|
return { status: "ok", ...getBuildInfo() };
|
|
} catch {
|
|
return reply.code(503).send({ status: "unavailable" });
|
|
}
|
|
});
|
|
|
|
server.get("/version", async (_request, reply) => {
|
|
reply.header("Cache-Control", "no-store");
|
|
return getBuildInfo();
|
|
});
|
|
|
|
server.get("/ping", async () => {
|
|
// Testquery gegen DB
|
|
const result = await server.db.execute("SELECT NOW()");
|
|
|
|
return {
|
|
status: "ok",
|
|
db: JSON.stringify(result.rows[0]),
|
|
};
|
|
});
|
|
}
|