import { Hono } from 'hono'; import { cors } from 'hono/cors'; import { AppContext } from './utils'; import publicRoutes from './routes/public'; import adminRoutes from './routes/admin'; import { agentic } from './routes/external'; import { liveRoutes } from './routes/live-location'; const app = new Hono(); app.use( '*', cors({ origin: '*', allowHeaders: ['Content-Type', 'Authorization', 'X-MAuth-Token', 'x-mworld-origin', 'mAuthAgenticToken'], allowMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], }) ); app.route('/api', publicRoutes); app.route('/api/admin', adminRoutes); app.onError((err, c) => { console.error('Unhandled Server Error:', err); return c.json({ success: false, msg: err.message || 'Internal server error' }, 500); }); app.route('/', agentic); app.route('/api', liveRoutes); export default app;