strongly type proxyConfig
Signed-off-by: Matt Benson <gudnabrsam@gmail.com>
This commit is contained in:
@@ -21,7 +21,6 @@ import {
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouterInternal } from './service/router';
|
||||
import { proxyEndpointsExtensionPoint } from '@backstage/plugin-proxy-node/alpha';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
|
||||
/**
|
||||
* The proxy backend plugin.
|
||||
@@ -34,7 +33,7 @@ export const proxyPlugin = createBackendPlugin({
|
||||
const additionalEndpoints = {};
|
||||
|
||||
env.registerExtensionPoint(proxyEndpointsExtensionPoint, {
|
||||
addProxyEndpoints(endpoints: JsonObject) {
|
||||
addProxyEndpoints(endpoints) {
|
||||
Object.assign(additionalEndpoints, endpoints);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,7 +20,6 @@ import Router from 'express-promise-router';
|
||||
import {
|
||||
createProxyMiddleware,
|
||||
fixRequestBody,
|
||||
Options,
|
||||
RequestHandler,
|
||||
} from 'http-proxy-middleware';
|
||||
import { Logger } from 'winston';
|
||||
@@ -31,6 +30,7 @@ import {
|
||||
HttpRouterService,
|
||||
RootConfigService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { ProxyConfig } from '@backstage/plugin-proxy-node/alpha';
|
||||
|
||||
// A list of headers that are always forwarded to the proxy targets.
|
||||
const safeForwardHeaders = [
|
||||
@@ -66,12 +66,6 @@ export interface RouterOptions {
|
||||
additionalEndpoints?: JsonObject;
|
||||
}
|
||||
|
||||
export interface ProxyConfig extends Options {
|
||||
allowedMethods?: string[];
|
||||
allowedHeaders?: string[];
|
||||
reviveRequestBody?: boolean;
|
||||
}
|
||||
|
||||
// Creates a proxy middleware, possibly with defaults added on top of the
|
||||
// given config.
|
||||
export function buildMiddleware(
|
||||
@@ -88,7 +82,7 @@ export function buildMiddleware(
|
||||
fullConfig = { target: config };
|
||||
credentialsPolicy = 'require';
|
||||
} else {
|
||||
const { credentials, ...rest } = config as any;
|
||||
const { credentials, ...rest } = config;
|
||||
fullConfig = rest;
|
||||
credentialsPolicy = credentials ?? 'require';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user