How to Customize the Strapi Back-end (Services, Routes, Controllers, Queries) using TypeScript

Every back-end service in existence has some form of system in place that enables them to receive requests and act on them appropriately (providing some response). Services, routes, and controllers are all represented in such servers. Strapi also has this system in place and offers ways for you to customize them to your preferences, such as adding capabilities or developing new ones.

This is a companion discussion topic for the original entry at

Great guide, Alex!

I’m wondering - when I create a custom controller and use the entity service - the return format is not the same as when you use Strapi’s default controllers. You know, by default you get your return object wrapped in data- and attributes-fields. When using entity service, you get a more “flat” return object.

Do you know if there’s a way to convert this flatter object to a format like { data: { attributes: … }, meta: } (like the default controllers)?

Thanks for the tutorial!
I am usig strapi v4 and i get a type error on the

data: content_schemas.GetAttributesValues<"api::article.article">;
... =;

The error says:
Property ‘publishedAt’ does not exist on type ‘GetAttributesValues<“api::article.article”>’.ts(2339)

Can you help me out?

Thank You