nodebestpractices icon indicating copy to clipboard operation
nodebestpractices copied to clipboard

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

Open goldbergyoni opened this issue 3 years ago • 14 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

goldbergyoni avatar Nov 30 '21 11:11 goldbergyoni

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?

goldbergyoni avatar Nov 30 '21 11:11 goldbergyoni

Whether it is actively maintained (express ahem ahem).

elektronik2k5 avatar Nov 30 '21 16:11 elektronik2k5

  • 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

goldbergyoni avatar Nov 30 '21 16:11 goldbergyoni

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

rluvaton avatar Nov 30 '21 18:11 rluvaton

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.

josh-hemphill avatar Nov 30 '21 18:11 josh-hemphill

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

mikicho avatar Nov 30 '21 20:11 mikicho

OpenAPI (Swagger) support

rluvaton avatar Nov 30 '21 20:11 rluvaton

Project size comparison: small, medium, and large

galezra avatar Dec 06 '21 22:12 galezra

Mature / Stable (express ahem ahem) :laughing:

trasherdk avatar Dec 08 '21 07:12 trasherdk

Whether or not it's opinionated or not:

Platform level
Express No
Fastify Yes *
Nestjs Very

* I'm still on the fence about this

rluvaton avatar Dec 13 '21 19:12 rluvaton

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 avatar Jan 10 '22 03:01 jiayisheji

@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

goldbergyoni avatar Jan 24 '22 10:01 goldbergyoni

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! 💚

stale[bot] avatar Apr 27 '22 16:04 stale[bot]