You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from 9.0.0 to the latest version the objects injected by decorators to controllers are undefined.
import{Response}from'koa';import'reflect-metadata';import{Get,JsonController,Res}from'routing-controllers';import{autoInjectable}from'tsyringe';import{Controller}from'../interface';import{StatusCodes}from'http-status-codes';
@JsonController('/example')
@autoInjectable()exportclassExampleControllerimplementsController{constructor(){}
@Get()asyncprocess(@Res()response: Response){console.log('inside controller');// this is logged ✅console.log(response);// this is undefined ❌response.status=StatusCodes.OKresponse.body={some: 'response'}returnresponse;}}
Expected behavior
Should return the response object
Actual behavior
{
"name": "TypeError",
"message": "Cannot set properties of undefined (setting 'status')",
"stack": "TypeError: Cannot set properties of undefined (setting 'status')\n.....
}
The text was updated successfully, but these errors were encountered:
It took me a good while to try to debug this. Unfortunately tsyringe is the issue here. If you remove @autoInjectable() and replace it with typedi for example, it works fine. Seems like @autoInjectable alters the class somehow and the param resolution is not working because the registered class is different from the actual.
Description
After upgrading from 9.0.0 to the latest version the objects injected by decorators to controllers are undefined.
Expected behavior
Should return the response object
Actual behavior
The text was updated successfully, but these errors were encountered: