Hello! I would like to know if it is possible to maintain the NestJS-esque way of returning an object directly in a controller method but at the same time specifying a different HTTP response code depending on method logic.
In other words, I want to know if there is a way to turn this:
res.status(variableAssignedInIfElse).json(payload);
Into:
return payload;```
As I am using TypeScript I really like the idea of controller methods returning objects instead of tinkering with the underlying transport.
Thanks!
Edit: The code below doesn't work as far as I have tested.
res.status(var);
return payload;