bank-api-gateway
API Gateway for Bank Integration using Express Gateway
Usage
To start the API Gateway:
npm start
The gateway starts on port 3040 locally.
Description
Gateway Configuration
The config for Gateway is in gateway.config.yml
The configuration includes:
apiEndpoints
: which defines the host where the Gateway receives the requestserviceEndpoints
: the endpoints where the request is forwarded topipelines
: Maps the apiEndpoints to serviceEndpoints and defines which policies to apply to each
Note: The policies
section defines all the policies available, but not all are used. It also includes some custom policies/plugins (described below).
Plugins
Express Gateway allows the use of plugins for customizations.
These can be defined locally or can be published as an npm module
.
bank-auth/redirect
This plugin receives the /auth
request from core and redirects it to the auth server.
Query params for the redirect URL are added using a template file, the path to which is provided in the config.
bank-auth/callback
This plugin receives the callback from the auth server. The path for callback is provided in the query parameters when redirecting to auth server (see redirect
plugin).
Each customer will have their own callback
plugin since the steps to get the access_token
might be different. Once the token is received, the response is transformed to what core expects (see docs/auth-api/callback
for the schema)
analytics-plugin
The analytics plugin intercepts all request from core and logs an analytics event.
This plugin is agnostic to the type of request and just logs two events: BANK_API_REQUEST
and BANK_API_SUCCESS
/BANK_API_ERROR
with the API path added in properties.
Conditions
Each custom plugin has two conditions attached to it:
pathMatch
: matches exact pathspathRegExp
: matches a regex path
By adding this condition, we ensure that responses from only certain endpoints are transformed.
The conditions can be used as follows:
- condition:
name: pathMatch
match: /api/v1/exchangeRates
- condition:
name: pathRegExpMatch
match: /api/v1/exchangeRates\?*
If the request contains query params, use pathRegExpMatch
and a wildcard char (*
) as shown above.
Running with Kubernetes
Bank API Gateway can be run locally against a dev Kubernetes bot through Tilt.dev. Setup and running instructions can be found in this confluence document.
Workflow
This repository uses Github Flow workflow starting v4.14. The workflow change is documented here.