strongly type proxyConfig

Signed-off-by: Matt Benson <gudnabrsam@gmail.com>
This commit is contained in:
Matt Benson
2024-11-14 18:30:39 -06:00
parent 11b001cf4d
commit ca2f9c29de
6 changed files with 36 additions and 17 deletions
+3 -2
View File
@@ -49,11 +49,12 @@
},
"dependencies": {
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/types": "workspace:^"
"http-proxy-middleware": "^2.0.0"
},
"devDependencies": {
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@backstage/config": "workspace:^"
"@backstage/config": "workspace:^",
"@types/http-proxy-middleware": "^1.0.0"
}
}
+14 -2
View File
@@ -4,12 +4,24 @@
```ts
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { Options } from 'http-proxy-middleware';
// @alpha
export interface ProxyConfig extends Options {
// (undocumented)
allowedHeaders?: string[];
// (undocumented)
allowedMethods?: string[];
// (undocumented)
credentials?: 'require' | 'forward' | 'dangerously-allow-unauthenticated';
// (undocumented)
reviveRequestBody?: boolean;
}
// @alpha
export interface ProxyEndpointsExtensionPoint {
// (undocumented)
addProxyEndpoints(endpoints: JsonObject): void;
addProxyEndpoints(endpoints: Record<string, string | ProxyConfig>): void;
}
// @alpha
+14 -2
View File
@@ -14,7 +14,19 @@
* limitations under the License.
*/
import { createExtensionPoint } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { Options } from 'http-proxy-middleware';
/**
* http-proxy-middleware proxy config interface.
*
* @alpha
*/
export interface ProxyConfig extends Options {
allowedMethods?: string[];
allowedHeaders?: string[];
reviveRequestBody?: boolean;
credentials?: 'require' | 'forward' | 'dangerously-allow-unauthenticated';
}
/**
* Extension point interface for managing proxy endpoints.
@@ -22,7 +34,7 @@ import { JsonObject } from '@backstage/types';
* @alpha
*/
export interface ProxyEndpointsExtensionPoint {
addProxyEndpoints(endpoints: JsonObject): void;
addProxyEndpoints(endpoints: Record<string, string | ProxyConfig>): void;
}
/**