DEV Community

Cover image for What Does Express.js Abstract Away?
Neel-Vekariya
Neel-Vekariya

Posted on

What Does Express.js Abstract Away?

In the past, we talked about the general deeper understanding about what Express.js actually is, what problem it tries to solve, and what existed before Express. But another question is: what abstraction does it introduce?

If you've read my previous posts, you know that Express.js provides an abstraction over Node.js's HTTP module. In this post, we'll go deeper and explore what those abstractions actually are.

The most common central abstraction, the low-level processing of an HTTP request into a programmable pipeline of middleware and routes. This is a broad perspective of the Express.js abstraction. But this broad abstraction has many small abstractions. And those abstractions are:

*) Route Matching

Express abstracts manually route matching. It takes responsibility for matching routes for incoming requests. It abstracts that task and gives a simple way to use routes without the complexity of matching routes.

*) Route Parameters:

The next abstraction Express.js provides is parsing request parameters for us, so we don't have to handle them manually. It hides the mechanics of matching and extracting that value. Without it, you might have to manually parse the parameters.

*) Request Processing:

Express abstracts raw HTTP request information into data that is easily accessible to the application. The task of processing raw information of the request is abstracted by Express.

*) Middleware:

Express allows you to represent cross-cutting request processing as reasonable functions. Instead of manually deciding everything inside one HTTP callback, it gives functionality to compose the application out of functions that process the request sequentially.

*) Composition Model:

Express gives you compose behaviour where each piece has a focused responsibility. That’s much more scalable than putting everything into one request.

Express makes application development easier by abstracting some of the complexity, but it does not abstract away everything involved in building an application.

It doesn’t decide:

  • How my business should work
  • How I should store users
  • Which database I should use
  • How an order should be calculated
  • How payment should work

Top comments (0)