goldbergyoni / nodebestpractices

:white_check_mark: The Node.js best practices list (July 2024)
https://twitter.com/nodepractices/
Creative Commons Attribution Share Alike 4.0 International
99.23k stars 10.08k forks source link

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

Open goldbergyoni opened 2 years ago

goldbergyoni commented 2 years ago

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 commented 2 years ago

Suggesting things to compare:

elektronik2k5 commented 2 years ago

Whether it is actively maintained (express ahem ahem).

goldbergyoni commented 2 years ago
rluvaton commented 2 years ago

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

josh-hemphill commented 2 years ago

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.

mikicho commented 2 years ago
rluvaton commented 2 years ago

OpenAPI (Swagger) support

galezra commented 2 years ago

Project size comparison: small, medium, and large

trasherdk commented 2 years ago

Mature / Stable (express ahem ahem) :laughing:

rluvaton commented 2 years ago
Whether or not it's opinionated or not: Platform level
Express No
Fastify Yes *
Nestjs Very

* I'm still on the fence about this

jiayisheji commented 2 years ago

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.

goldbergyoni commented 2 years ago

@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

stale[bot] commented 2 years ago

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