import { serve } from '@hono/node-server' import { serveStatic } from '@hono/node-server/serve-static' import { Hono } from 'hono' import { healthRouter } from './routes/health.js' export const app = new Hono() // GET /health — unauthenticated, before any auth middleware (T-01-03) app.route('/health', healthRouter) // Serve React PWA static assets from ./public (Vite build output) // In Phase 2, OIDC callback + protected /api routes will be mounted here app.use('/assets/*', serveStatic({ root: './public' })) app.get('*', serveStatic({ path: './public/index.html' })) // Only start the HTTP server when this module is run directly (not imported in tests) if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/^.*\//, ''))) { serve({ fetch: app.fetch, port: 3000 }, (info) => { console.log(`FamilySync API running on http://localhost:${info.port}`) }) }