goldbergyoni / nodebestpractices

:white_check_mark: The Node.js best practices list (February 2024)

Home Page:https://twitter.com/nodepractices/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New bullet: Choose your framework - Express vs Nest vs Fastify

goldbergyoni opened this issue · comments

I'm about to PR a new architecture bullet that suggests making a thoughtful decision between the major frameworks. The main message is about WHEN to use each. A detailed comparison table will be included as well.

Help me here with ideas about what dimensions/features should we compare between the three.

These ideas will then be put in the comparison table.

Any Ideas?

cc @mikicho @rluvaton

Suggesting things to compare:

  • Performance with our own benchmark
  • Popularity: Stars, commits, Google trend, npm downloads
  • Validation approach - Class-based validator vs JSON schema vs none
  • Which layers are covered by this framework - Almost nothing for Express, Nest covers also error handling, DAL...
  • Authorization support
  • Many more
  • What else?

Whether it is actively maintained (express ahem ahem).

  • Per layer features. For example, data access capabilities: (A) Does it closes connection when app exits (B) Does it synchronizes DB connection opening with the server.listen (C) Plugin/module for major DBs

Same as #984, but let's keep this one...

commented

Might also want to mention JTD (JSON Type Definition) support. AJV has been moving towards it, and Fastify technically supports it now. I had to get them to add an option boolean to turn off JSON Schema auto-fixes that Fastify itself was doing. So if you turn that off and use their separate AJV compiler package which separates the version of AJV used from the version of Fastify, you can use JTD and have all your route properties fully typed.
The reason AJV and Fastify are moving towards JTD and away from JSON Schema is that JSON Schema was created to mirror how things were done with XML Schemas which could express complex data structures that no common programming language had any native types for. So JTD has a much smaller and concise set of types that Typescript happens to be able to boil down supported types.

  • app load (Request Per Minutes)
  • typescript or javascript

OpenAPI (Swagger) support

Project size comparison: small, medium, and large

Mature / Stable (express ahem ahem) 😆

Whether or not it's opinionated or not:

Platform level
Express No
Fastify Yes *
Nestjs Very

* I'm still on the fence about this

commented

Express and Fastify at the same level.

Nestjs encapsulates Express and Fastify on top of it.

Consider NestJS if you like Typescript + Java.

If you use Angular, you can do full-stack projects with NestJS.

@jiayisheji I find Fastify to be more on Nest level. It has official DB connectors, rate-limiting, health-check and many more plugins. It's a pretty rich framework. But yes, less than Nest

commented

Hello there! 👋
This issue has gone silent. Eerily silent. ⏳
We currently close issues after 100 days of inactivity. It has been 90 days since the last update here.
If needed, you can keep it open by replying here.
Thanks for being a part of the Node.js Best Practices community! 💚