API with NestJS #3. Authenticating users with bcrypt, Passport, JWT, and cookies
I&#x27;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&#x27;t use for a new project. They&#x27;ve done a lot of work to build a system that, so long as you stay within very narrow lines and don&#x27;t ask too many questions, feels very cohesive and consistent. The unfortunate part is that it shakes apart at speed if you don&#x27;t do both of those things.<p>People make a lot of hay about the NestJS dependency injection system, and my intuition is that a lot of it is that it&#x27;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&#x27;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 <i>need</i> and what they <i>export</i> 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 <i>every consumer</i>. It&#x27;s a high-boilerplate devolved service locator rather than dependency injection.<p>&quot;Pretty critical misunderstanding&quot; has become my default description of big parts of NestJS as I&#x27;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 &quot;that&#x27;s a great idea!&quot;, and then implemented that half-a-description...poorly. The &quot;microservices&quot; 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&#x27;ve somehow implemented <i>single-node CQRS</i>, made it impossible to distribute, and declared victory and went home.<p>It is better to <i>not provide official support</i> 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&#x27;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&#x27;ve rolled out what read to me as lock-in, don&#x27;t-play-nice-with-the-ecosystem-as-a-whole &quot;features&quot;, like their poorly intentioned CLI &quot;monorepo tooling rather than just using lerna for multi-modulestuff like the rest of the world. Also like the future-forecasted &quot;Nest CLI plugins&quot; for things like linting otherwise bonkers misbehaviors[0]. As somebody who&#x27;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 <i>own</i> 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 &quot;cron-like&quot; 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&#x27;t a community, it&#x27;s a single-source vendor, and in 2020 that&#x27;s weird to me.<p>I&#x27;ve used a lot of NestJS but I can&#x27;t really countenance using it for new projects, and I can&#x27;t recommend it to others.<p>[0] - <a href="https:&#x2F;&#x2F;github.com&#x2F;nestjs&#x2F;nest&#x2F;issues&#x2F;3279" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nestjs&#x2F;nest&#x2F;issues&#x2F;3279</a>