Custom controller which returns data and attributes wrapping

Hi!

I’m creating a custom controller in which I use entityService.findMany(). It returns the data in a pretty “clean” way when you compare it to the default controllers return format. The default controllers return an entry in the format:

{
data: {
id,
attributes: (…X)
}
meta,
}

… while the entityService just returns everything in a flatter fashion, like:

{
(…X)
}

I actually prefer the entityService’s way of returning. However, I have a fairly large frontend project built in TypeScript, in which I would have to do a whole lot of work of the types if I were to start using this custom controller which uses the entityService’s return format.

I can of course “manually” adjust the return object so that it looks like the default format, but that gets very ugly in deep populations/relations.

Is there any option or so, to make the entityService’s response look like the default controller’s format?

Thanks in advance

1 Like