In case someone is reading this, I found this way to do it in strapi 4.0 in case someone finds it useful
The bad thing is that the other controllers are disabled, plus I have not found a way to update them. But otherwise it works, I hope it works for you.
Controller:
module.exports = createCoreController('api::inventario-usa.inventario-usa', ({ strapi }) => ({
async findUid(ctx) {
const { slug} = ctx.params;
console.log(slug);
const response= await strapi.db.query('api::your-collection').findOne({
where: {
Code:slug,
},
});
return response;
}));
Route:
module.exports = {
routes: [
{
method: 'GET',
path: '/search/product/:slug',
handler:'your-collection.findUid',
}
]
}