ServerRoutes & API
Architecture
How the router, middleware, and handler bridge interact.
createHonoRouter() composes feature route modules and global middleware. Each route handler builds a HandlerContext and executes an Effect program via runHandlerBridge so errors and responses are normalized.
Key points:
- Routes are namespaced under
/api/v1. - Route modules follow the
createXxxRoutes()factory pattern (seecrm/server/routes/*). - Hono route handlers must call
getHandlerContext(c)to build the typedHandlerContextused by services.
Example flow: HTTP -> middleware -> route handler -> runHandlerBridge -> APIResponse