addressing review suggestions

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-01-28 13:51:47 +00:00
parent 947f1098ee
commit 27e1ab0ec4
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
'@backstage/plugin-proxy-backend': patch
---
If one of the configured proxies is configured badly enough to cause an exception when the middleware is being built it can now be configured to pass the bad proxy by and continue the server startup. Previously the backend would fail to startup.
Adds a new option `skipInvalidTargets` for the proxy `createRouter` which allows the proxy backend to be started with an invalid proxy configuration. If configured, it will simply skip the failed proxy and mount the other valid proxies.
To configure it to pass by failing proxies:
@@ -11,7 +11,7 @@ const router = await createRouter({
config,
logger,
discovery,
skipBrokenProxies: true,
skipInvalidProxies: true,
});
```
@@ -113,7 +113,7 @@ describe('createRouter', () => {
config,
logger,
discovery,
skipBrokenProxies: true,
skipInvalidProxies: true,
});
expect((logger.warn as jest.Mock).mock.calls[0][0]).toEqual(
'skipped configuring /test due to Proxy target must be a string',
+2 -2
View File
@@ -51,7 +51,7 @@ export interface RouterOptions {
logger: Logger;
config: Config;
discovery: PluginEndpointDiscovery;
skipBrokenProxies?: boolean;
skipInvalidProxies?: boolean;
}
export interface ProxyConfig extends Options {
@@ -194,7 +194,7 @@ export async function createRouter(
buildMiddleware(pathPrefix, options.logger, route, proxyRouteConfig),
);
} catch (e) {
if (options.skipBrokenProxies) {
if (options.skipInvalidProxies) {
options.logger.warn(`skipped configuring ${route} due to ${e.message}`);
} else {
throw e;