添加Health健康检查端点

This commit is contained in:
CN-JS-HuiBai
2026-04-05 21:13:27 +08:00
parent a103c7dbf5
commit e8e23c5af8
3 changed files with 68 additions and 2 deletions

View File

@@ -18,9 +18,20 @@ function initPool() {
});
}
async function checkHealth() {
try {
if (!pool) return { status: 'down', error: 'Database pool not initialized' };
await pool.query('SELECT 1');
return { status: 'up' };
} catch (err) {
return { status: 'down', error: err.message };
}
}
initPool();
module.exports = {
query: (...args) => pool.query(...args),
initPool
initPool,
checkHealth
};