import { countAvailableMitrasFromCache } from '../../services/mitra-status.service.js' /** * Public bestie-availability beacon. * * GET /api/public/bestie/available โ†’ 200 { available: bool } * * Unauthenticated by design: the SHome1st CTA must reflect global availability * BEFORE the user has any JWT (see `requirement/flow_customer.mermaid.md` ยง1 + * router.dart's "fresh / unauthenticated users land on Home directly" carve-out). * * Output is intentionally a single boolean โ€” no `count`, no IDs, no metadata โ€” * so this endpoint leaks no operational signal beyond "at least one bestie is * online right now". Backed by the same 10s in-memory cache that bounds DB * load regardless of poller count. * * The auth'd `/api/client/mitra-availability` route is kept for CC/debug * callers that need the raw count. */ export const publicBestieAvailabilityRoutes = async (app) => { app.get('/available', async (_request, reply) => { const { available } = await countAvailableMitrasFromCache() return reply.send({ success: true, data: { available } }) }) }