Explanation
Structured logs and /health endpoints tell you when a database or dependency is down.
Code example
javascriptapp.get("/health", async (_req, res) => {
try {
await prisma.$queryRaw`SELECT 1`;
res.json({ ok: true });
} catch {
res.status(503).json({ ok: false, db: "down" });
}
});Helpful resources
Exercise
Add /health that checks the database and log method, path, and status for every request.
