HTTP Pipeline
Copy-Paste Example
More Examples
safeParse().data back to ctx.request.body.
Runtime And Lifecycle Notes
new Http({ port })creates a Koa app and afind-my-wayrouter.http.use(middleware)registers Koa middleware beforelisten().http.listen()returns a close function.http.load(directory, options)scans*.controller.{ts,js,tsx,jsx,mjs}by suffix.defineController()supports method-only, method-plus-middlewares, and metadata-plus-Zod forms.- Response plugins transform handler return values and set
ctx.bodywhen the final result is notundefined.
Anti-Patterns
- Setting
ctx.bodyand returning a value from the same controller. - Loading controllers after starting only because an old example does it; prefer load before listen in new code.
- Using old validation examples that assume Zod coercion rewrote
ctx.query.
Verification Checklist
- Controller files default-export
defineController(...)or an array of controllers. - Controllers return response values.
- Boot service awaits
http.load()beforehttp.listen(). - Zod schemas are used for validation, and parsed data is explicitly parsed when needed.