Now, there are no interceptors. How can I globally format result before sending to client?
just using regular middlewares. Example can be found here.
just using regular middlewares. Example can be found here.
@pleerock I don't think you can, the express driver sends the response before 'after' middlewares get called so currently there are no way to format response returned from @Get, @Post, etc handlers.
@pleerock the interceptor is good, why you remove it?
@pleerock @19majkel94
I have read this discussion #110 .
I don't really know about koa. Maybe it's useless in koa, but it very useful in express which without overriding method of response can't intercept the returning results.
I don't consider interceptor as middleware. I'd like it to be a result processor before sending to the client.
Before, I write an interceptor to format my result. Now I need to override the method which I don't want to care about.
Interceptors are very useful. Not sure why you would want to remove them?
Yes, it is maybe possible to achieve the same functionality by using the solution, but this does not fit well with routing controllers class style. Why would I want to change res,.send() instead of having an elegant solution like @InterceptorGlobal()?
Interceptors are awesome, please do not kill them, or at least give us a good reason why you have to remove them.
@pleerock without interceptors is there a way to achieve the same functionality using classes/services and DI (typedi)?
You don't need an integration inside framework, just use the language features 馃槈
https://github.com/pleerock/routing-controllers/issues/110#issuecomment-302504119
@19majkel94 this works on a controller level, but with this solution you cannot implement global interceptor applied to all application endpoints.
Yeah, but what's the problem with one-line decorator for controller?
Maybe let's @pleerock talk, we've decided to remove this feature as the sample use-case wasn't enough to convince that it's a good feature and it seemed that only a few people used it.
But formating REST responses to the unified format is a good use-case, I would also like to see and error interceptor for the same reason.
@19majkel94, the problem is because some developer on a project can forget to put that controller. Also, following "separation of concerns", there are usually more than few interceptors. Having an option to decorate classes/components as global application wide interceptors is (was 馃槩 ) a good feature. And I assure you it was used - not sure how you came to a conclusion that no one is using it.
Right some people are using this functionality, some do not. Its probably was a mistake to remove this functionality because sometimes it can be really useful for users. And as we can see users are using this functionality. Returned it back and will be released in 0.7.0-alpha.10
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Right some people are using this functionality, some do not. Its probably was a mistake to remove this functionality because sometimes it can be really useful for users. And as we can see users are using this functionality. Returned it back and will be released in
0.7.0-alpha.10