3 ms·
I've spent the last eighteen months using NestJS. I can simultaneously call it a good step forward in the Node space and something I wouldn't use for a new proj
by eropple 6y ago
I've spent the last eighteen months using NestJS. I can simultaneously call it a good step forward in the Node space and something I wouldn't use for a new project. They've done a lot of work to build a system that, so long as you stay within very narrow lines and don't ask too many questions, feels very cohesive and consistent. The unfortunate part is that it shakes apart at speed if you don't do both of those things.
People make a lot of hay about the NestJS dependency injection system, and my intuition is that a lot of it is that it's a novel concept to a lot of the folks running into it. If you come from a Spring or related background, however, I think it's pretty clear that NestJS has a pretty critical misunderstanding of dependency injection. Modules are hardwired together--`BarModule` requires `FooModule`rather than just declaring what they need and what they export and allowing the dependency resolver to figure it out regardless of what module they come from. As-is, you cannot replace a dependency coming from `FooModule` with one, say, from `Foo2Module` without changing every consumer. It's a high-boilerplate devolved service locator rather than dependency injection.
"Pretty critical misunderstanding" has become my default description of big parts of NestJS as I've gotten deeper into its use over the last year and a half. This description really does fit a lot of aspects of the system. It often feels as though the implementors read half a description of this or that, decided "that's a great idea!", and then implemented that half-a-description...poorly. The "microservices" concept (really just RPC, and not particularly play-nice-with-others RPC) is a good example, as is the really clunky access to WebSockets. CQRS is another prime example, as they've somehow implemented single-node CQRS, made it impossible to distribute, and declared victory and went home.
It is better to not provide official support for something if that official support is going to be so full-stop awful, because that official support will choke out attempts to innovate in the space because you've already taken the mindshare for the problem at hand. Which dovetails into the problem that will probably end up putting NestJS in the dustbin as soon as somebody else comes up with a competitor: the NestJS team seems to have what feels like at best an oblivious and at worst a rivalrous relationship with their community and with Node as a whole. Over the last year they've rolled out what read to me as lock-in, don't-play-nice-with-the-ecosystem-as-a-whole "features", like their poorly intentioned CLI "monorepo tooling rather than just using lerna for multi-modulestuff like the rest of the world. Also like the future-forecasted "Nest CLI plugins" for things like linting otherwise bonkers misbehaviors[0]. As somebody who's written a bunch of open-source modules for NestJS, I consistently get the feeling that Kamil would really prefer it if developers just shut up and took his stuff and made apps (maybe paying him along the way?), rather than building their own open-source stuff alongside it. I still have a very bad taste in my mouth from the way that they just stomped on the `nest-schedule` project by added a less-featureful but otherwise identical "cron-like" gizmo to NestJS core without so much as a nod to the community member who wrote the better one before they did. The idea seems to be that NestJS isn't a community, it's a single-source vendor, and in 2020 that's weird to me.
I've used a lot of NestJS but I can't really countenance using it for new projects, and I can't recommend it to others.
[0] - https://github.com/nestjs/nest/issues/3279 https://github.com/nestjs/nest/issues/3279
- adamkl 6y agoI don't have as much experience working with Nest.js as you do, but I can see some validity in some of the things you mention. Nest.js tries to have "answers" for everything (i.e. CQRS, MQTT, Kafka, etc., etc., etc), but I do wonder how well implemented these answers are (vs. checking of a list of "completed" features.. Their documentation certainly looks impressive when it comes to breadth). I think if you stick to the core concepts of MVC with some simple DI (and if you are building something that pushes the limits of that DI system, maybe its too big), Nest.js can take a team of developers new to Node.js and enable them to quickly build well structured applications (certainly with higher quality than the average express applications I've seen in the wild). Do I think its the perfect swiss-army knife of Node.js server side development? No, but for a team of regular developers, I think it fills an important void in the Node.js landscape (the same void that was filled by Spring MVC in Java). As with everything tech related, it all depends on the use case.
- eropple 6y agoI don't disagree with anything you've said. But, that said, I feel like there's a brick wall there for NestJS users and I feel like the incentives of the NestJS core team are hard to ascertain. Uncertainty creates risk; if you're comfortable with that level of risk, that's great. I'm growing to not be comfortable with it. If there was a roadmap and a set of principles for governance I'd feel much better about it, but I also have trouble seeing that ever actually happen. > I do wonder how well implemented these answers are Not well, tbh. "Microservices", as mentioned, are useless. CQRS is fundamentally misunderstood. Their OpenAPI 3 libraries (and I will cop to some bias here, my frustration with their OAS implementation got to the point where I wrote a better one[0]) are implemented in a developer-unfriendly way that's totally separated from validation so there's a ton of diplication of work. (And let's not even talk about validation! `class-validator` is a mess. "Pipes" are pretty silly as a concept. Fastify uses `ajv` under the hood; there's not a great reason why everybody else doesn't, too.) As you say: checkmarks. A lot of checkmarks. But then you pick up the corner of the carpet and the subfloor's chewed through. [0] - https://github.com/eropple/nestjs-openapi3 https://github.com/eropple/nestjs-openapi3
- deleted 6y ago[deleted]