From f7727391f117f49d48d042afc25e54f02ddb6815 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 1 Jul 2026 12:22:20 +0300 Subject: [PATCH] Add healthcheck endpoint --- apps/api/src/app.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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);