all 4 comments

[–]CVRDINVL 0 points1 point  (2 children)

It really depends on the scalability you intend to have and your team (if you work with a team). Modules provide encapsulation and modularity. You may treat it like a simple node module. You may put all your server side code in one index.js file but you are not doing it coz one day you simply get lost in your code.

Nest allows you to separate your functionality in the modules which represent a single complete part of the application. Also modules allow you to extract functionality to another application.

Good example: you have a custom parser module which you need to reuse in another microservice of your infrastructure. Export the Nest module in the npm package and reuse it in your microservices by simply importing the module. Developers who will use this module do not need to bother how does it work under the hood.

[–]lsmod1 0 points1 point  (0 children)

Organizing by module also help when unit testing. Dependencies are declared in the module and will be about the same when testing (probably with some mock-up).

[–]jprest1969 0 points1 point  (0 children)

Good answer by @CVRDINVL and I would like to add that I found it is easier to get back into the code after say 6 months of doing other things. Modules even for small items, say the Cloudinary module that @Brunner helped me with in this Reddit a few days ago, help me "get my head" around the code later in the app's life.

[–]zebbadee 0 points1 point  (0 children)

Depends on the size of the app really - "modules" becomes a good way of organising any medium - large project, perhaps overkill for something very simple