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:
- Services + DAO for supporting database other than redis
- Credential types
- Admin REST API routes
- HTTP and HTTPS servers routes
- HTTP and HTTPS servers custom events (like upgrade for websockets)
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:
- enable the base plugin framework within Express Gateway
- enable extension points for the first three entities: conditions, policies and routes
- 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:
- Create new services
- Explore new credential types
- Examine new models
- 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.