[object Object]

← back to Stars of Design

api/health: include counts (designers/firms) + uptime_s + as_of (asim parity)

eef66c30179186a446264d6d2112bdce6d0806da · 2026-05-13 09:56:04 -0700 · Steve Abrams

Files touched

Diff

commit eef66c30179186a446264d6d2112bdce6d0806da
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed May 13 09:56:04 2026 -0700

    api/health: include counts (designers/firms) + uptime_s + as_of (asim parity)
---
 routes/public.js | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/routes/public.js b/routes/public.js
index 46f1f49..fc551a2 100644
--- a/routes/public.js
+++ b/routes/public.js
@@ -41,13 +41,23 @@ router.get('/healthz', (req, res) => {
 });
 
 // /api/health — slightly heavier liveness + count snapshot. Mirrors asim
-// /api/health pattern; uses the same shared statsPool. 30s cache stays
-// fresh enough for monitoring tools without hammering pg.
+// /api/health pattern; uses the same shared statsPool. no-store so monitor
+// tools always see fresh state. Includes uptime_s and as_of for ops dashboards.
 router.get('/api/health', async (_req, res) => {
   try {
     res.setHeader('Cache-Control', 'no-store');
-    const r = await statsPool.query('SELECT 1 AS ok');
-    res.json({ ok: r.rows[0].ok === 1, ts: Date.now() });
+    const r = await statsPool.query(`
+      SELECT
+        (SELECT count(*) FROM sod_designers WHERE role IS NULL OR role <> 'Manufacturer Rep') AS designers,
+        (SELECT count(*) FROM sod_firms) AS firms`);
+    const row = r.rows[0] || {};
+    res.json({
+      ok:        true,
+      counts:    { designers: Number(row.designers || 0), firms: Number(row.firms || 0) },
+      uptime_s:  Math.floor(process.uptime()),
+      ts:        Date.now(),
+      as_of:     new Date().toISOString(),
+    });
   } catch (e) {
     res.status(500).json({ ok: false, error: e.message });
   }

← 3774c03 smoke: 6 new checks for /api/{designers,firms,clients}/featu  ·  back to Stars of Design  ·  smoke: uptime_s + counts.designers assertions on /api/health 90ada6d →