Add healthcheck endpoint

This commit is contained in:
Codex
2026-07-01 12:22:20 +03:00
parent 2beebb4968
commit f7727391f1

View File

@@ -66,6 +66,18 @@ app.get('/api/health', async (_req, res) => {
} }
}); });
app.get('/api/healthcheck', async (_req, res) => {
try {
await Promise.race([
db.raw('select 1'),
new Promise((_, reject) => setTimeout(() => reject(new Error('db-timeout')), 1000)),
]);
res.json({ success: true, data: { status: 'ok' } });
} catch (err: any) {
res.status(503).json({ success: false, error: 'db_unavailable' });
}
});
// ── Глобальный rate limit на /api/* — ДО docs чтобы не было unauthenticated DoS на swagger.json // ── Глобальный rate limit на /api/* — ДО docs чтобы не было unauthenticated DoS на swagger.json
app.use('/api', globalLimiter); app.use('/api', globalLimiter);