The Challenge π¨
I recently built BEnder , a framework-agnostic boilerplate that runs on Express , Fastify , Hono , or Elysia using a single codebase.
Adding Koa is another to single truth concept.
The Problem: Context vs. Req/Res
Most Node frameworks (Express, Fastify) follow the standard callback signature:
( req , res ) => void
Enter fullscreen mode
Exit fullscreen mode
Koa , however, uses a Context object:
( ctx , next ) => Promise < void >
Enter fullscreen mode
Exit fullscreen mode
This broke my unified IRequest and IResponse interfaces. My "Synapses" (route handlers) expected to call res.json() , but Koa expects you to set ctx.body .
The Solution: The Adapter Pattern π§©
I wrote a KoaRouterShim that wraps every handler.β¦