Live data from Hacker News

Ask HN: Is Express still "de-facto" for building Node back ends?

news.ycombinator.com

51–60 of 100 posts

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#51

I love threads like this, it's so stereotypical JS. OP asks if it's the de-facto choice which it objectively is, but everyone recommends their pet project or favourite library instead.

To be fair for me the first 10 root comments almost all recommend Express or Fastly, no obscure pet projects or anything. So there does seem to be a pretty clear consensus.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#52

Follow-up question: Is there any backend framework which uses the fetch API. That is, where requests are standard Request objects ( https://developer.mozilla.org/en-US/docs/Web/API/Request ) and where you send (or return, or yield) standard Response objects ( https://developer.mozilla.org/en-US/docs/Web/API/Response )? I’m teaching a highschool kid web development and it would be very nice to be able to teach the sam…

Isn't that what node-fetch is for?

https://www.npmjs.com/package/node-fetch

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#53
post #4

It's still the most popular but for the past couple of years it hasn't seen any major updates and some people question if the project is abandoned. I switched to Fastify and haven't looked back.

some people use the word abandoned... some people use the word "finished"

indeed. I hate projects that make changes for no reason. If it does everything its supposed to do and does it well, it's just done. Go work on something else.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#54

Maybe it's still standard, but if you don't want to shoot yourself in the foot, just stay away from it. Express's API is horrible. It's not integrated with Promises (async/await) at all, so be prepared to wrap every async endpoint (so probably all of them) with a custom error handling wrapper. If you don't (and don't have a big catch-block around the whole implementation), an unhandled error will hang the connection…

The thing is, express's foot guns are well known and well documented, and you basically just enumerated them. If you pick another framework then you'll be left exploring its footguns on your own. That may or may not be worth it to you, but it's not obvious to me that choosing the well-known framework is a worse choice than choosing the ones that try to solve its problems but don't yet have the rough edges discovered and documented.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#55

I love threads like this, it's so stereotypical JS. OP asks if it's the de-facto choice which it objectively is, but everyone recommends their pet project or favourite library instead.

FWIW I was planning to respond “yes, it is the de facto solution, even if I wish it weren’t” and probably leave it at that. Granted I don’t have my pet project to recommend (I left it behind with previous employer), and maybe I would if I had it to recommend. But I’d still acknowledge first that express is the de facto solution.

Also FWIW, there are a bunch of other popular options… but nearly all of them have roughly the same interface and follow the same general principles as express. Again, I wish it weren’t so. But you’re right, that isn’t responsive to the question being asked.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#56
post #4

It's still the most popular but for the past couple of years it hasn't seen any major updates and some people question if the project is abandoned. I switched to Fastify and haven't looked back.

some people use the word abandoned... some people use the word "finished"

It’s neither. There are still occasional commits to its pre-release branch, last I checked. It’s more fair to say it’s stable than anything else.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#57
post #6

It seems like it. There are alternatives like Koa and Fastify, but none of seem to strike quite the balance that express does. I pray that one day express 5 will get released and they’ll finally fix the whole async middleware not handling errors properly thing though. That’s gotta be one of the most annoying quirks that has just been quietly sitting there untouched for years at this point. Maybe one day. I guess ther…

> async middleware not handling errors properly thing though Can you expand on this? Error handling in middleware is pretty well documented.

Anytime an error happens inside an async middleware in express, you have to explicitly catch it and pass it directly to the `next` function, otherwise it'll just disappear and any kind of error logging middleware you have later on will never see it. In synchronous functions any error is passed automatically. You can write more middleware to address this, or just manually catch everything, but it just means more boilerplate. There's no reason to expect different types of middleware to have different behaviour unless you already know. It's not catastrophic, but I expect more consistent design from such an established library, especially considering how long this has been an issue.

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#59
All of the responses talk about a framework and I know you're thinking you need one too. But, I'm more curious about your plans to host things.

The reason I ask is because there are alternatives, like Google Cloud Functions [0], where you don't need a framework at all. You just write a handler and you're done. Connect it with Github actions for deployment.

There are other services out there, but I like GCF cause it'll auto scale. Need a database? Cloud SQL Postgres. Need a queue... Cloud Tasks... etc... so many problems solved in a relatively non-vendor lockin way.

EDIT: I'm getting downvoted for trying to make a helpful comment to the OP. Good work HN!

[0] https://cloud.google.com/functions/docs/console-quickstart

Re: Ask HN: Is Express still "de-facto" for building Node back ends?

#60
I've been on various projects that utilized Express, Koa, and NestJS (which wraps Express or Fastify).

Of the three, I'd choose Koa again over the others. Their design works better with modern javascript (async/await). While there may be fewer middleware packages for Koa than Express, it's usually not that hard to write your own if you can't find what you need.

For NestJS I didn't care for the decorator-driven "Spring-like" design. In JS codebases it's more natural to take a functional approach.

Post reply on HN