R
R
Rag'n' Code Man2021-05-30 21:30:06
Node.js
Rag'n' Code Man, 2021-05-30 21:30:06

What's the point of NestJS modules?

Started learning NestJS and got a bit carried away with module assignments.

Even the documentation only says

A module is a class marked with the Module decorator


What do they essentially represent? Containers for services and controllers?

Those. we have controllers for, for example, working with users in the database, called UserController, then, for all this, we have a UserService and all this is a UserModule? And some ProductsController should not be included in all this, maybe it is engaged in completely different things that have nothing to do with users?

Services -> Module <- Controllers

Right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Sviridov, 2021-05-31
@iDmitriyWinX

This decorator essentially describes what modules the current module depends on, what controllers and services it has - that is, roughly speaking, a description of the module or something, its configuration. And the module itself is a collection of some kind of logic (services, controllers), united in meaning (located in the same folder). That something like applications in Django inside the project, if you dealt with this. This is necessary so that the project does not turn into a mess. So in your case, users and products are two different modules.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question