Choosing a framework is a major concern for any team and many criteria come into play while looking for a framework to use. Frameworks allow us to align our codebase to a defined practise. This can sometimes be the difference between order and chaos. Some factors to consider when choosing a framework are ease of use, community support, developer documentation, team experience with background functionality of the framework as well as similar frameworks.
Node JS developers have an array of frameworks to choose from. Popular frameworks include Next.js, Express.js, Koa, Hapi, Molecular, Seneca, and Fastify. So, why pick NestJS?
Having experienced engineers is great but you still need a framework that has wide community support. NestJS currently has 31.2K stars on Github as well as a very active discord channel where you can get amazing support from industry leaders as well as the framework creators.
NestJS provides an out-of-the-box modular approach that is flexible enough to be extended and still enforces SOLID practises. This makes NestJS excellent for projects with a small code base that is likely to become large.
NestJS has a powerful CLI that automates mundane tasks, support for Typescript, code sharing, monorepo support, powerful plugins, libraries (swagger, rabbitMQ e.t.c ) as well as its interesting custom decorators.
At Telios, most of our engineers have extensive experience in developing web applications using Spring and Angular. NestJS borrowed a lot of concepts from these excellent frameworks, and therefore, makes it easier for the team to apply its experience on the Node JS platform.
Under the hood, NestJS makes use of server-side frameworks like Express and Fastify. This allows us to use plugins that are available for the underlying frameworks.
For existing legacy applications it is easy to port these libraries to follow Nest’s approach. We only needed to write the modules that allow us to plug into Nest. For our engineers, it was simply easy to catch up with the Nest concepts as underlying architecture imitates angular and spring boot.
As an engineering team, we currently maintain three layers for our applications; the repository layer which interacts with the data, the service layer where we handle all business logic as well as the controller. These layers become easy for us using Nest as it supports the separation of concern with its modules feature.
Annotations have always been useful for us in writing readable code. It became very easy for us to do Aspect-Oriented Programming(AOP). For example, in our controllers, we simply annotate it with @Public to remove security restrictions. These simple out of the box tweaks would not have been possible without NestJS support for AOP. We have been able to utilise all these amazing out of the box features to allow scalability and reusability for our apps.
Additionally, dependency injection becomes very smooth, just like in spring boot where services are scoped, Nest provides us with this amazing feature. It really seems like we have been writing spring boot with typescript.
As a team, we are building tools that will support our processes and we are really keen on DRY (Don’t Repeat Yourself), not just in our coding practice but even in our engineering practice, and having a framework like NestJS allows us to maintain this shift in our code base. Over the period we will be sharing some of our practices not just with only our tools but also with our engineering practices.