I know NestJs is on top of express JS and can be on fastify, I completed the express JS library project in the Mozilla training site but for many reasons like the architecture of the app and discussions that I saw on web about problematic situations with express and modern JS like async await etc… I searched for a more reliable choice and sails JS, nest and feathers came up, feathers was awesome but NestJs had a very well documentation and I avoided type script for a while, but it now seems to be everywhere, and I hope with nest I could get to know it better and the practical use of it, in frontend I honestly could not find a good reason for using it beside it's a trend, except for angular 2 plus, and don't get me wrong angular is one of the reasons I hope to come around TS.
Short Version
so this is my current situation frontend developer(vue & svelte mostly) a few months in NodeJS atmosphere (express and hapi) my question is should I stick to hapi &/ express or go with NestJs &/ alternatives like feathers and sails, please forgive my lack of experience in writing in English friends
CodePudding user response:
In my opinion, You should go for nestjs. Typescript is the future. Once you are into typescript, you will love using it. Nestjs gives a very clean structure for building web apps. It can be compared to well established frameworks like LARAVEL, DJANGO in case of functionalities. yes it may not be as popular but it is growing. I really recommend using nestjs. The upside is, you don't always need Typescript for it. Nest can work fine with plain javascript as well.
CodePudding user response:
Nest.js & Typescript is a framework for enterprise-level applications which provides a clear structure and guidelines of how things should be.
So for the beginner pros are:
- OOP (SOLID) in TS/JS
- Introducing the latest LTS features of TS, like decorators, dependency injections, and so on.
- In build ESLint, prettier, and monorepo mod which can be activated via Nest CLI.
- Easy deployment via docker-compose for microservice architecture.
You can't achieve these things via such old frameworks like Express (something else)
As for the cons:
It's hard to understand why there is a
contoller
file,service
file, and why there are multiplemodule
files withforRoot
andforRootAsync
connections to DBs and so on.In time, it will be difficult to write/build projects w/o Nestjs because it's very good, but has a bit different pattern of programming.
@Afaq mentioned that TS is the future (and Nestjs as well), but it's a bit wrong. JS as a native language always inherits the best available options from TS, and it did with CoffeeScript and so on. So one day in the future, you could wake up and look at your TS codebase as a legacy without appropriate support, while native technology goes forward.