Express.js Middleware and your API Strategy

Sep 7, 2017 · 3 min read

Why Express.js Middleware?

When we set out to build an open source API Gateway, we had a lot of tough choices ahead of us. What frameworks should we use? How do we provide the best possible experience for developers?

One of the key reasons why we built Express Gateway on ExpressJS is because of an existing rich ecosystem of 3,000+ middleware modules already being used out of the box with Express.js. Not all Express.js modules are relevant to the API gateway use case — but many are.

So, almost all API gateway use cases can utilize an existing Express module.

In fact, that’s exactly what happened — all initial features supported by Express Gateway were entirely built using existing Express middleware as a starting point.

Doing this has realized the following benefits:

  • Speed up to time to value by not starting from scratch
  • Simplicity through familiarity — by building on something that is already familiar in the community.

All about those Express.js Gateway Plugins

Express Gateway Plugins extend Express Gateway. ANY Express.js middleware can be taken and rolled into Express Gateway.

Initially, Express Gateway features are part of the core offering. Instead of refactoring the features into separate plugins. We built the plugin foundation first and decided to bundle everything as part of the core along with the the plugin foundation to get the Express Gateway out sooner.

What Are Plugin Extension Points?

The Express Gateway Plugin Framework will support the following extension points for Express Gateway entities:

  1. Conditions
  2. Policies
  3. Routes
  4. Services + DAO for supporting database other than redis
  5. Credential types
  6. Models
  7. Admin REST API routes
  8. HTTP and HTTPS servers routes
  9. HTTP and HTTPS servers custom events (like upgrade for websockets)
  10. CLI

So, as you can see from above, the plugin capabilities are extensive.

Below is an overview of the iterative development planning going into the Express Gateway Plugin Framework as well as future plugins.

Iteration 1: A Plugin Example

In the first iteration, the team is going to do complete three things:

  1. enable the base plugin framework within Express Gateway
  2. enable extension points for the first three entities: conditions, policies and routes
  3. provide a reference example of a plugin (express-gateway-plugin-example) that the plugin framework will be able to install to illustrate the mechanics of how a plugin extends Express Gateway

The plugin framework allows you to use Express.js Middleware in Express Gateway. Also, it takes advantage of existing services, models and metadata.

Iteration 2: More Extension Points

At this point, plugins can utilize existing Express Gateway entities.

So, the next iteration will extend the plugin framework to address the next three extension points:

  1. Create new services
  2. Explore new credential types
  3. Examine new models
  4. CLI (additional Yeoman generators)

By enabling these extension points, more complex plugins can add functionality and data that is not included as part of the Express Gateway core.

Iteration 3: Real Middleware Plugin Example

After the community has seen the reference example for a plugin, the team will take an existing Express middleware that has been highly sought after — JWT Authentication and chronicle a “how to” of taking a middleware and transforming it into an Express Gateway plugin.


Written by

Builders of Express Serverless Platform, multi-cloud platform for microservices. Sponsor of @express_gateway, an #opensource #API Gateway built on Express.js.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade