https://github.com/kiva/protocol-gateway
API gateway for Kiva Protocol microservices
https://github.com/kiva/protocol-gateway
protocol protocol-backend
Last synced: 27 days ago
JSON representation
API gateway for Kiva Protocol microservices
- Host: GitHub
- URL: https://github.com/kiva/protocol-gateway
- Owner: kiva
- License: apache-2.0
- Created: 2020-10-06T10:54:16.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T15:44:03.000Z (over 3 years ago)
- Last Synced: 2024-04-13T09:17:37.894Z (about 2 years ago)
- Topics: protocol, protocol-backend
- Language: TypeScript
- Homepage:
- Size: 1.95 MB
- Stars: 1
- Watchers: 10
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.txt
Awesome Lists containing this project
README
# Gateway
aka: NestJS Gateway, Gateway Service
## Quickstart
We can run the gateway in isolation with the docker compose in this directory
or as part of the complete backend stack. See master
[README](https://github.com/kiva/protocol-integration-tests/blob/main/README.md) for details.
## Dependencies
Dependencies are components which are required to build and run the service
locally and in production. Dependencies include language, libraries, other
services, data, config, environment, platform.
### Language / Libraries:
- NestJS
- http-proxy-middleware: this is what the gateway uses to proxy requests to mapped microservice routes
- See `package.json` in this directory for the full list of library dependencies
### Service
[Note: Gateway will run without any other services (TODO: confirm this) but
will only be able to service ping healthchecks]
- Wallet Sync Service (plaintext HTTP, no authentication required, internal to VPC)
### Data
Gateway is stateless (no database)
### Env / Config
Locally (and in CICD) the service uses the .env config file in this directory
which is populated from the dotEnvFiles.contents in the top level of the
protocol repo. It uses that .env file to specify which environment the service
is running in and then uses that information to pull config from
`src/config/env.json` in this directory.
In deployed environments the service uses the kubernetes secrets file to set
the environment which then determines which section of the config json the
service reads (from the `src/config/env.json` in this directory).
## Features / Aspects
The gateway routes requests coming from the ingress to the specific internal
services required. It also authenticates and authorizes requests via Auth0. It
also generates a request ID to attach to the request sent onward if that isn't
provided by the request.
- All routes are defined in gateway.routes.ts (and documented with Swagger).
- Routes are protected by AuthenticationMiddleware which calls the auth0 service to verify the Authorization header.
- Traced by opentracing.
- Logs to stdout/stderr in human readable and JSON format.
- Rate limiting
- CORS whitelisting
- Standard vulnerability protections (via helmet)
## Known Bugs / Quirks
None