Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of Express over plain Node.JS?

So far, I see these benefits:

  • Consistent Routing to modules
  • Consistent Middleware interface (akin to a filter?)
  • Handling for things like postdata, session management, static file serving, etc.

However, routing is very easily done with if statements and regex (that's what I do in Perl and Java already), and postdata and static file serving - well there's a module for that. So is it just that Express handles these things out of the box or is there a more significant feature I'm missing?

Maybe it's my point of view.. I'm writing my own webserver as part of a larger project, so maybe it's just that I'm replacing Express' more obvious features whereas many developers expect a webserver to be useable right out of the box?

On the other hand, I thought that people commonly made apps that listen on a TCP port, and then use ngix or some other HTTP proxy server for routing? Is Express supposed to replace this model?

like image 888
700 Software Avatar asked Mar 03 '15 02:03

700 Software


2 Answers

You can read for yourself the API that Express offers here and get a direct feel for what it adds to the base http server.

A partial list of features:

  • All sorts of routing features including routing, separate handlers for put, get, post, etc..., wildcard handling, variables pulled automatically from URLs, etc...
  • Sub routers
  • Static file serving
  • A framework that many popular template engines plugin to
  • View caching
  • Routing by case sensitivity or no case sensitivity
  • A middleware framework which tons of third party NPM modules plug into
  • eTag support
  • All sorts of useful properties and methods to query info on the request
  • All sorts of methods for constructing the response

Most folks building a web app would prefer to start with a web server and a framework and be able to use a wide variety of pre-built NPM modules that work with the framework rather than build all that stuff themselves.

nginx is sometimes used in concert with node.js (it has many features), but not usually as the main functionality that Express offers.

like image 76
jfriend00 Avatar answered Nov 14 '22 17:11

jfriend00


The documentation of Node is so bad, you barely can use it.
Express instead shows clearly what they offer and how you can use it.
One big reason against Node.

Let's take the Response Object as an example:

Node Documentation:
https://nodejs.org/api/http.html

Express Documentation:
http://expressjs.com/en/api.html#res

like image 23
Ernst Robert Avatar answered Nov 14 '22 17:11

Ernst Robert