diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index e880f89..715ee66 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -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 app.use('/api', globalLimiter);