Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage in Express / Koa using TypeScript and Routing Controllers Framework.
curl http://localhost/api/users // show json as expected
curl http://localhost/homepage // show HTML page as expected
curl http://localhost/api/users // show HTML page (!!NOT EXPECTED!!)
When use
@Render
in Koa, it will break all api request, all API request will return a html template.How to produce
Create a html render controller
Create a api json controller
Test
Reason code
https://github.com/typestack/routing-controllers/blob/24556885e58e1022531881eecb963c363e9933a9/src/driver/koa/KoaDriver.ts#L245-L251
in KoaDriver.ts, handleSuccess will register a render middleware. so that every request will goes to the middleware, even a JSON api.