Yes, the transform plugin is the way to go.
But I’ve recently learned that it’s all a joke.
You see, core controllers invoke the transformResponse function which iterates over the service response and produces this highly impractical data/meta/attributes structure. This takes time.
Then, the middleware offered by the transform plugin iterates again over that transformed response and flattens it. Which takes time again.
A performant way would be to disable that transformResponse function alltogether, or at least the part that wraps all non-id field within attributes.
Maybe patch-package could be used for that.