Now let us look at some of the practical implementations of API Gateway available. In this section, we will look at options like Express Gateway, Netflix OSS, message brokers, NGINX as a reverse proxy, and tools available for designing gateway.
HTTP proxy is an HTTP programmable library for proxying. This is helpful for applying things such as reverse proxy or load balancing. http-proxy
available in npm has more than 1 lakh download per day. To achieve request dispatching we can use http-proxy
. This is a piece of cake and can be achieved like this:
const express = require('express') const httpProxy = require('express-http-proxy') const app = express(); const productServiceProxy= httpProxy('https://10.0.0.1/') //10.0.0.1 is product container location // Authentication app.use((req, res, next) => { // TODO: Central Authentication logic for all next() }) // Proxy request app.get('/products/:productId', (req, res, next...