Live data from Hacker News

Node.js 20 is now available

nodejs.org

31–40 of 101 posts

Re: Node.js 20 is now available

#31
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

Express is still fine to use. To me it's either express or fastify. A lot of opinions in the JS world.

This. Fastify is so great. Unfortunately, the documentation became worse after v2 because Matteo was too laissez-faire in approving new doc contributions.

Imo the docs need a major re-write, beginning at "getting started". New users don't know whether they should use "fastify-cli gen", "npm init fastify" or copy manually from the "getting started"-guide.

And people also tried to push their fastify-plugins to the top of the plugins-site by adding a "@username" for every plugin: https://i.imgur.com/hHyI6JO.png (left are the old docs, right are the current docs where ppl try to game the system).

Also, fastify-cli needs to rework the custom options in typescript projects imo.

Ok, that's all. Other than that, fastify rocks!

Re: Node.js 20 is now available

#32

Earlier quoted context omitted.

Who cares how old something is, if it works well, why not use it? You can easily avoid callback-hell by making the callback you pass in to expressjs async and use await inside of it, without much drawbacks. Just because the first closure into express is a callback doesn't mean you need to use callbacks everywhere, just use await/generators/whatever you want in your application code. expressjs at this point is battle-…

> You can easily avoid callback-hell by making the callback you pass in to expressjs async and use await inside of it, without much drawbacks. I thought this was slightly awkward due to error handling, but it looks like Express 5 (in beta) supports async callbacks natively.

I'm sorry to point out that the first 5.0 alpha came out in 2014 and still hasn't been released. When people talk about the ecosystem/battle-tested-ness/quality of express I think that unfortunately doesn't extend to anything other than the latest major on npm. It's not "modern" but it's still a good tool.

Re: Node.js 20 is now available

#33
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

In the past 3 years I've built 4 apps (1 mid-size, 3 small-mid) using Apollo and IMO it's currently the best possible approach. I did a research for my latest app a half year ago looking for sensible alternatives and didn't really find any.

Re: Node.js 20 is now available

#34

With testing built into core, I’m looking forward to the reduction in complexity and number of external testing frameworks. I generally chose tape/ava in the past and vitest these days, but it’s awesome that now a very simple testing mechanism is available in core

A shame it's not using `expect` syntax, which recently was also adopted by bun.

Re: Node.js 20 is now available

#35
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

You can use this small lib for expressjs https://github.com/express-promise-router/express-promise-ro...

Re: Node.js 20 is now available

#36

With testing built into core, I’m looking forward to the reduction in complexity and number of external testing frameworks. I generally chose tape/ava in the past and vitest these days, but it’s awesome that now a very simple testing mechanism is available in core

A shame it's not using `expect` syntax, which recently was also adopted by bun.

Well I'm sure they knew about it -- maybe there's an impassioned debate on a GH Issue/Discussion somewhere on why they left it out.

The refactoring of expect to a reusable library (that hopefully everyone could depend on) would be awesome as well. AFAIK there are multiple expect() implementations out there right now, would be nice if there was one.

Re: Node.js 20 is now available

#37
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

Who cares how old something is, if it works well, why not use it? You can easily avoid callback-hell by making the callback you pass in to expressjs async and use await inside of it, without much drawbacks. Just because the first closure into express is a callback doesn't mean you need to use callbacks everywhere, just use await/generators/whatever you want in your application code. expressjs at this point is battle-…

I haven't used Express in ten years, but imo `async (req, res, next) => ...` would mainly be attractive if failure was automatically handled and you could `await next()` to post-process the response. Though it would still help you write async code inside that route.

Since iirc you send responses directly from handlers in Express, I'm not sure the latter is possible even with express-promise-router since you basically need downstream routes/middleware to return a Response object rather than send it directly.

I think Express is never going to unify with Koa's direction since it's just too disruptive to Express' ecosystem (the v5.x branch is stale) which is probably for the best.

Re: Node.js 20 is now available

#38

With testing built into core, I’m looking forward to the reduction in complexity and number of external testing frameworks. I generally chose tape/ava in the past and vitest these days, but it’s awesome that now a very simple testing mechanism is available in core

Same. Every time I dive into a repo using Jest it infuriates me. So slow. The built in test runner is great.

Re: Node.js 20 is now available

#39
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

I've used this - https://adonisjs.com/ - I don't think it's "standard". Is there such a thing? I guess Express was a de-facto standard. I'm a bit biased since I come from Laravel background, so adonis feels familiar.

Express (fka Connect) is standard in the sense that the "middleware" API design was/is part of the CommonJs server-side JavaScript (SSJS) initiative [1] from which Node.js originated and insofar as you can write a middleware that plugs into Node.js' core http API and express.js at the same time since these invoke your code using the same basic callback, which was deemed desirable for portability back when Node.js wasn't the only SSJS framework around. Express/connect draws inspiration from Ruby's Sinatra/Rack and Python's WSGI, and is based on JSGI/JackJs.

[1]: https://wiki.commonjs.org

Re: Node.js 20 is now available

#40
post #6

What is the standard web application backend framework for Node.js these days, is it Koa? As I understand it express is quite dated because of the callback structure. I have been confused recently with the moving best practices. What is the server architecture Next.js is most often plugged into?

Lack of async support in middleware makes Express a non starter these days. Koa, Fastify, AdonisJS, Hapi, Nest are all great.
Post reply on HN