feat(proxy): implement proxy backend plugin

This commit is contained in:
Ivan Shmidt
2020-07-08 09:25:27 +02:00
parent f3f684fbb9
commit a05a8f805d
12 changed files with 300 additions and 9 deletions
+37
View File
@@ -0,0 +1,37 @@
# Proxy backend plugin
This is the backend plugin that enables proxy definitions to be declared in and read from app-config.yaml.
Relies on the `http-proxy-middleware` package.
## Getting Started
This backend plugin can be started in a standalone mode from directly in this package
with `yarn start`. However, it will have limited functionality and that process is
most convenient when developing the plugin itself.
To run it within the backend do:
1. Register the router in `packages/backend/src/index.ts`:
```
const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));
const service = createServiceBuilder(module)
.loadConfig(configReader)
/** several different routers */
.addRouter('/', await proxy(proxyEnv));
```
2. Start the backend
```bash
yarn workspace example-backend start
```
This will launch the full example backend.
## Links
- (http-proxy-middleware)[https://www.npmjs.com/package/http-proxy-middleware]
- (The Backstage homepage)[https://backstage.io]