feat: add health check route
Implement handleHealth endpoint for Bun.serve to verify DB connection. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d915814277
commit
be93a06918
@@ -0,0 +1,13 @@
|
||||
import logger from '../utils/logger.js';
|
||||
import { db } from '../db/index.js';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const handleHealth = async (req) => {
|
||||
try {
|
||||
await db.execute(sql`SELECT 1`);
|
||||
return Response.json({ status: 'ok' }, { status: 200 });
|
||||
} catch (error) {
|
||||
logger.error('Health check failed', { error: error.message });
|
||||
return Response.json({ status: 'error', error: error.message }, { status: 500 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user