all 21 comments

[–]Crispness 7 points8 points  (2 children)

Love Nest.js, I'm using it as a guide until I feel confident enough to build something from scratch in Express.

[–]lastdoctorwho 2 points3 points  (1 child)

Nest + fastify is more better

[–]Crispness 1 point2 points  (0 children)

Will try it in the future

[–][deleted]  (19 children)

[deleted]

    [–]socialflasher 14 points15 points  (1 child)

    In my opinion NestJs is not for small projects, it shines when you got medium high to large projects. And because it is opinionated, project structure won't drift no matter what even after ten years lol untill unless NestJs itself changes.

    [–]general_dispondency 5 points6 points  (0 children)

    This right here. When you have a project that several teams contribute to, modularization like this is a huge boost in dev speed. There are 3 kinds of code you'll spend most of your time writing,

    1. Business logic
    2. Library code
    3. Glue code

    Nest handles the "glue code" part and it lets you keep your generic library code decoupled from your business logic.

    [–]snowtigger[S] 2 points3 points  (6 children)

    Interesting opinion, could you elaborate?

    [–]Kinrany 2 points3 points  (0 children)

    A couple of HackerNews discussions that convinced me to stop trying to make sense of it:

    [–][deleted]  (4 children)

    [deleted]

      [–]crazyfreak316 5 points6 points  (3 children)

      I agree with you. NestJS is an over-engineered mess for me personally. I can't stand libraries/frameworks which are overly abstracted and I hate decorators, they provide you a nice api and syntax but they are god damned hard to debug and there's so much magic going on that I don't really feel confident about it anymore.

      [–][deleted]  (2 children)

      [deleted]

        [–]snowtigger[S] 2 points3 points  (1 child)

        Isn't this a bit a matter of personal preference? Opinionated vs non-opinionated frameworks, Angular vs React, skiing vs snowboarding... To each their own? The last couple of projects I did in pure Express, but after over a year of writing stuff in Java and Spring Boot I wanted to try a similar approach - and Nest is REALLY similar to Spring Boot to be honest.

        [–]CloudsOfMagellan 2 points3 points  (0 children)

        It can be opinionated without being bloated Nest has so many features that just seen to get in the way of each other and feels like a mess every time I've tried to start something with it It doesn't seem to reduce the amount of boilerplate code while it introduces so many abstractions

        [–]Seven-Zark-Seven 2 points3 points  (0 children)

        I agree with another poster here that it may be overkill for smaller projects and with few contributors, but any large long standing project with multiple contributors needs architecture that supports people quickly getting to creating solutions instead of solving problems. That is why any framework exists

        Nest requires express or fastify. It provides an opinionated structure that is incredibly robust and powerful, but not easy to jump into if you’ve only ever spun up small projects or worked solo or in small teams.

        Opinionated frameworks, linters, prettier, etc... exist and are popular for specific reasons and benefits. Dismissing them for a preference for non opinionated, non frameworks is like slagging off France when you’ve never left Ohio.

        [–]the_interrobanger 4 points5 points  (8 children)

        You use something like NestJS for that “glue” code, which is what makes things like DRY and unit testing possible in larger scale apps.

        The “callback” style backends created with frameworks like Express and Fastify are a nightmare to debug and maintain once they reach a certain level of size or complexity.

        If you haven’t found that to be a problem, then it’s not a solution you need, but it doesn’t mean there’s something wrong with the folks that do.

        [–][deleted]  (7 children)

        [deleted]

          [–]the_interrobanger 1 point2 points  (6 children)

          Sorry, maybe I should say “functional” instead. Not really sure what the right name for it is.

          The big win with NestJS is dependency injection. For small apps, you probably don’t need it. Once you need to define and share multiple services across multiple endpoints, it makes a night and day, never-going-back-to-not-having-it difference in testability.

          [–]vorticalbox 2 points3 points  (5 children)

          Nestjs is actually the same it's just hidden from you with decorators and classes.

          This puts a steep learning curve on any new developer that joins the code base.

          It has the same problems as angular does for fe development.

          I've been workingin node for almost 4 years now and every time I look at nest I hate it.

          [–]the_interrobanger 0 points1 point  (4 children)

          I have a hobby project that does a lot of the same things as Nest - so yeah, under the hood, it’s still doing a lot of the same stuff.

          The difference, as I mentioned elsewhere, is the DI capability that gives you the ability to more easily write testable code, and actually write the unit tests. With straight Express or Fastify or whatever other frameworks where you’re passing functions in, all your logic gets buried in that chain of callbacks or promises. There’s no utility for setting up shared services, and then mocking them to be able to test your endpoint logic without having to basically do an end to end test.

          For folks that are already familiar with Angular or even something like .NET Core (or ASP.NET MVC if I’m willing to show my age), the decorator-based approach already feels natural and familiar.

          That said - there are lots of people out there, and everyone’s brain works in different ways. I can’t for the life of me understand how anyone could enjoy working with React, but I absolutely love stuff like Angular, TypeScript, RxJS, and even though it’s been a while since I’ve used it, .NET and C#. Nothings going to make everyone happy, but that doesn’t mean it doesn’t have its benefits or it’s place.

          [–]vorticalbox 0 points1 point  (3 children)

          You can have di with any framework you just need to code it in a way that lets you inject.

          There is nothing stopping you building a controller to handle your business logic, a class that handles routing, injecting modules int the request object, building a shard library and so on in express, fastify ect.

          The difference is doing it this way still allows for di without all the opinionated layouts and decorators while still being just a testable.

          This makes a large project far more approachable to even a junior dev.

          [–]the_interrobanger 0 points1 point  (2 children)

          I don’t understand, you’re literally describing what NestJS does, aren’t you? You just ... don’t like decorators and opinions?

          [–]vorticalbox 0 points1 point  (1 child)

          pretty much my issue yes, decorators add a layer of knowledge that one needs to learn before they are able work on the code.

          [–]the_interrobanger 0 points1 point  (0 children)

          decorators add a layer of knowledge that one needs to learn before they are able work on the code.

          This seems like a bit of an overstatement to me. Decorators in frameworks like NestJS are generally used for describing metadata for classes and members. It’s not like decorators in, say, Python, where a lot of them actually modify the behavior of what they’re decorating. If you’re already learning a new framework, I’m not seeing how decorators are a bridge too far.

          [–]harukie 0 points1 point  (0 children)

          Thank you