r/javascript • • Mar 04 '23

Build & Deploy your own REST API with NodeJS and Express

https://galaxies.dev/node-express-api
0 Upvotes

12 comments sorted by

4

u/[deleted] Mar 04 '23

Oh look, another junk "create an API with node and express" article.

Imagine that.

1

u/Whoisjason Mar 04 '23

Lol - New developer here, less than a year. Honest question - what could they have done better? Why so salty? Is it that articles like this are a dime-a-dozen?

I agree that it isn't a phenomenal resource. It looks to me like they just tidied up the output of a chatGPT request and called it a blog post.

4

u/[deleted] Mar 04 '23

This same content has been regurgitated a hundred times over.

It's also typical of those that like to spam this sub with junk articles. It's one thing to spotlight your blog with useful information, it's another to do it with this junk.

Additionally, they rarely go into the more advanced features of express, that truly make it useful, like route security, middleware functions, etc.

2

u/gizamo Mar 04 '23

This article has been written hundreds of times over, and it hasn't changed in years.

what could they have done better?

Written about FeathersJS, which is a drop-in replacement for Express that offers way more capabilities. I haven't used Express since I heard about Feathers a couple years ago.

Koa is also better than Express.

0

u/jayerp Mar 04 '23

Why are they better than Express? I legit want to know why, I made a WebAPI in express because i heard it was easy to spin up from a blank file. Just a few highlights would be great.

1

u/gizamo Mar 04 '23

Imo, the top 5:

  1. It does everything express does.

  2. It is ~50% faster.

  3. V5 is all TS.

  4. Its APIs are independent of the transport mechanism.

  5. Endpoints can be automatically available thru REST (HTTP) or websockets, or both, and others. This is the biggest thing because it gives you real-time events out of the box. With express, you have to add that in, and it gets messy, imo.

Also, a common criticism is that the mental model differs from an MVC, which makes the learning curve trickier. But, imo, it's design pattern makes the structure cleaner and it makes testing easier and faster.

Oh, and the operations way, way faster with socket.io than plain express. I've never liked that comparison much because you can pile socket.io streaming on top of Express. But, even doing that, I much prefer the Feathers way of applying sockets alongside REST in the same structure.

If you want a bit more detail, the creator did an interesting run thru of V5 a month ago on Code Garden: https://youtu.be/NF5lkljVK6Q

0

u/jayerp Mar 04 '23

Sweet, those all seem like every good points, especially number 5. I’ll have to look into them now. Where I work we don’t tend to build a lot of JS based back-end but if we ever did it will be good to know that there are more and better alternatives to Express.

3

u/buddyfcb Mar 04 '23

Express is still extremely popular with about 30mil downloads per week. Feathers in contrast has about 57k. While popularity doesn‘t make it necessarily a good or better choice, it definately is a factor to consider because it brings a lot of ressources and greater community with it and that could make it a better framework for someone without a lot experience.

The best framework is the one that fits your and your clients needs best and that may very well be express.

That said, fastify and nestjs should also be mentioned here. You may also look into these if you want to build an opinion on node backend frameworks. Especially nestjs, which is not the next express-like framework and really does things different. My personal favorite, but again, it may not be yours. :)

0

u/jayerp Mar 04 '23

The only thing popularity buys me is a larger community which means potentially a bigger pool to choose from to hire devs. I’m mainly interested in what it can do for me, technical benefits. Popularity I consider, just not initially nor primarily.

1

u/gizamo Mar 04 '23

No worries. Feathers is my favorite, but you may also want to check out Koa. For some, Feathers just doesn't click well because of the MVC disconnect. If that's the case, I'd recommend Koa over Express. Koa seems cleaner to me and it's also much faster. Cheers.

2

u/RappingScientist Mar 04 '23

One step up from a Hello World article

1

u/jayerp Mar 04 '23

Likely for traffic generation.