Modify API response to have a common format

success: true/false,
message: “”,
data: []/{}
Hi guys, I want to modify the API response for all endpoints to have the exact format above. I’ve achieved it using a middleware but after reading this article it turns out I shouldn’t do like that.

Could you please show me with a good approach?
Thank you very much!