J
J
jenya77712021-10-31 13:58:34
Node.js
jenya7771, 2021-10-31 13:58:34

How to separate controllers and services in Fastify?

Hello everyone, I started looking at the Fastify framework, and I immediately had a misunderstanding. Fastify has the ability, through plugins that can be registered at the time of application loading, to add various database connections or other instances to the req object and use them in controllers.

It turns out that there is no need to use services, or is it better to separate controllers and services to make the logic independent of the framework and reusable?

In the examples that I found on the git, there are usually no services, all the logic is in the controllers.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question