How to change the response of a find or findOne without having to override all of them?

I am trying to manipulate the response in the controllers directory, but it keeps asking me to add all the other controllers like update etc… how can I do it only for the finds?

This topic has been created from a Discord post (1232744395904782457) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

/**

  • controller
    */

import { factories } from “@strapi/strapi”;

module.exports = {
async find() {
return “strapi”;
},
};

export default factories.createCoreController(
“api::…”
);

Error: Error creating endpoint GET /xxxxx/:id: Handler not found                                  ││   "api::xxxx.findOne"

global middlewares is what you’d want to use, similar to my example though mine is route based

https://github.com/antokhio/strapi-plugin-untransform-response that’s how you override all transformResponse in all controllers

So if I install this i override them, and on top of that the response is normalized?

Instead of me having attributes etc?

You should look at the transformer plugin for v4, that does want you want. In Strapi 5 we are getting rid of the nested attributes

Yea it does, zero config

And it should be faster then a middleware

Ah ant I didn’t know you made a plugin <:ThinkEyes:642567846597230614>

But no gql

Yea that was some hack I pick up on discord

I don’t know what it is that

graphql, different option than REST

If you feel like picking up the transformer plugin to maintain ant since Daedalus is gone let me know :stuck_out_tongue:

Sure, I actually need it but I am still figuring out how to remove that private field

Azuna-san you could also look at the protected populate plugin if you don’t want to write the custom code