Monday 30 March 2020

NestJS, monoliths and project structure

Hey, I'm currently working on a complete rewrite of an e-learning web app for the company I work for. The first version has been done with pretty much only Express, while all the rest had been implemented without the aid of any framework/library. I wasn't part of the team during the first iteration, and the first problem I noticed when I got hired was the huge amounts of redundant, reused, non standardized chunks of code and patterns.Now that my role is to plan, coordinate and take part in the whole rewriting process and since using NodeJS is the only strict requirement I must fulfill, I'm guessing if NestJS could be the right candidate for the job, given that I've used the framework for some small projects and have gotten to love it, but my mind is filled with doubts and would love if any of you could help me sort some things out.The project is gonna be a big monolith, and this is not even questionable due to a number of reasons I really don't want to waste your time explaining (team size, experience, deadlines, etc..).The modular structure imposed by the NestJS is great to keep things clean, but I can't really imagine how could I "cleanly" get a monolith done with it. Imagine needing 4 subcontrollers (Web, Api, Admin-web, Admin-api) instead of one single controller per module. This would be pretty easy to pull off if modules could be structured in a tree-like form, but all I see in the guides are a bunch of modules existing on the same level, so I guess my best bet would be creating 4 controllers under the same module. Not very clean. NestJS's basic project structure is clearly great if you're going for a SPA on the front (get 1, maybe 2 Api controllers per module and you're done), but what about old-school backend-served Handlebars pages?Also, the courses hosted by the platform should have several activities included, like quizzes, tests, etc.. and they should be freely sortable and configurable by the course admins. I would implement each activity as a different module then have one generic activity module load the right activity-specific module based on a bunch of parameters. Would NestJS be able to handle this kind of dynamic structure?Clearly what I'm trying to find out is if the framework is capable of handling a big amount of deep modularity without going the microservice way or if I should stick to more close-to-the-metal-yet-battle-tested solutions like Express/Koa/Fastify to retain control over the project by implementing my own structural core logic.

Submitted March 30, 2020 at 03:03PM by _cappu

No comments:

Post a Comment