backend-app-api: Remove deprecated MiddlewareFactory

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2024-08-14 09:36:59 +02:00
parent 0ad13df777
commit 29ee082ed6
13 changed files with 15 additions and 255 deletions
+1 -60
View File
@@ -3,23 +3,15 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
/// <reference types="node" />
import type { AppConfig } from '@backstage/config';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import type { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import { CorsOptions } from 'cors';
import { ErrorRequestHandler } from 'express';
import { Format } from 'logform';
import { HelmetOptions } from 'helmet';
import * as http from 'http';
import { IdentityService } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
import { LoggerService } from '@backstage/backend-plugin-api';
import { RequestHandler } from 'express';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceFactoryCompat } from '@backstage/backend-plugin-api';
@@ -66,21 +58,6 @@ export interface CreateSpecializedBackendOptions {
defaultServiceFactories: ServiceFactory[];
}
// Warning: (ae-forgotten-export) The symbol "ExtendedHttpServer_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type ExtendedHttpServer = ExtendedHttpServer_2;
// Warning: (ae-forgotten-export) The symbol "HttpServerCertificateOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type HttpServerCertificateOptions = HttpServerCertificateOptions_2;
// Warning: (ae-forgotten-export) The symbol "HttpServerOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type HttpServerOptions = HttpServerOptions_2;
// @public @deprecated
export type IdentityFactoryOptions = {
issuer?: string;
@@ -105,42 +82,6 @@ export function loadBackendConfig(options: {
config: Config;
}>;
// @public @deprecated (undocumented)
export class MiddlewareFactory {
compression(): RequestHandler;
cors(): RequestHandler;
static create(options: MiddlewareFactoryOptions): MiddlewareFactory;
error(options?: MiddlewareFactoryErrorOptions): ErrorRequestHandler;
helmet(): RequestHandler;
logging(): RequestHandler;
notFound(): RequestHandler;
}
// Warning: (ae-forgotten-export) The symbol "MiddlewareFactoryErrorOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type MiddlewareFactoryErrorOptions = MiddlewareFactoryErrorOptions_2;
// Warning: (ae-forgotten-export) The symbol "MiddlewareFactoryOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type MiddlewareFactoryOptions = MiddlewareFactoryOptions_2;
// Warning: (ae-forgotten-export) The symbol "readCorsOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const readCorsOptions: typeof readCorsOptions_2;
// Warning: (ae-forgotten-export) The symbol "readHelmetOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const readHelmetOptions: typeof readHelmetOptions_2;
// Warning: (ae-forgotten-export) The symbol "readHttpServerOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const readHttpServerOptions: typeof readHttpServerOptions_2;
// @public @deprecated (undocumented)
export const tokenManagerServiceFactory: ServiceFactoryCompat<
TokenManagerService,
-183
View File
@@ -1,183 +0,0 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ErrorRequestHandler, RequestHandler } from 'express';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import {
readHttpServerOptions as _readHttpServerOptions,
createHttpServer as _createHttpServer,
MiddlewareFactory as _MiddlewareFactory,
readCorsOptions as _readCorsOptions,
readHelmetOptions as _readHelmetOptions,
type MiddlewareFactoryErrorOptions as _MiddlewareFactoryErrorOptions,
type MiddlewareFactoryOptions as _MiddlewareFactoryOptions,
type ExtendedHttpServer as _ExtendedHttpServer,
type HttpServerCertificateOptions as _HttpServerCertificateOptions,
type HttpServerOptions as _HttpServerOptions,
} from '../../../backend-defaults/src/entrypoints/rootHttpRouter/http';
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export const readHttpServerOptions = _readHttpServerOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export const readCorsOptions = _readCorsOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export const readHelmetOptions = _readHelmetOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export class MiddlewareFactory {
/**
* Creates a new {@link MiddlewareFactory}.
*/
static create(options: MiddlewareFactoryOptions) {
return new MiddlewareFactory(_MiddlewareFactory.create(options));
}
private constructor(private readonly impl: _MiddlewareFactory) {}
/**
* Returns a middleware that unconditionally produces a 404 error response.
*
* @remarks
*
* Typically you want to place this middleware at the end of the chain, such
* that it's the last one attempted after no other routes matched.
*
* @returns An Express request handler
*/
notFound(): RequestHandler {
return this.impl.notFound();
}
/**
* Returns the compression middleware.
*
* @remarks
*
* The middleware will attempt to compress response bodies for all requests
* that traverse through the middleware.
*/
compression(): RequestHandler {
return this.impl.compression();
}
/**
* Returns a request logging middleware.
*
* @remarks
*
* Typically you want to place this middleware at the start of the chain, such
* that it always logs requests whether they are "caught" by handlers farther
* down or not.
*
* @returns An Express request handler
*/
logging(): RequestHandler {
return this.impl.logging();
}
/**
* Returns a middleware that implements the helmet library.
*
* @remarks
*
* This middleware applies security policies to incoming requests and outgoing
* responses. It is configured using config keys such as `backend.csp`.
*
* @see {@link https://helmetjs.github.io/}
*
* @returns An Express request handler
*/
helmet(): RequestHandler {
return this.impl.helmet();
}
/**
* Returns a middleware that implements the cors library.
*
* @remarks
*
* This middleware handles CORS. It is configured using the config key
* `backend.cors`.
*
* @see {@link https://github.com/expressjs/cors}
*
* @returns An Express request handler
*/
cors(): RequestHandler {
return this.impl.cors();
}
/**
* Express middleware to handle errors during request processing.
*
* @remarks
*
* This is commonly the very last middleware in the chain.
*
* Its primary purpose is not to do translation of business logic exceptions,
* but rather to be a global catch-all for uncaught "fatal" errors that are
* expected to result in a 500 error. However, it also does handle some common
* error types (such as http-error exceptions, and the well-known error types
* in the `@backstage/errors` package) and returns the enclosed status code
* accordingly.
*
* It will also produce a response body with a serialized form of the error,
* unless a previous handler already did send a body. See
* {@link @backstage/errors#ErrorResponseBody} for the response shape used.
*
* @returns An Express error request handler
*/
error(options: MiddlewareFactoryErrorOptions = {}): ErrorRequestHandler {
return this.impl.error(options);
}
}
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export type MiddlewareFactoryErrorOptions = _MiddlewareFactoryErrorOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export type MiddlewareFactoryOptions = _MiddlewareFactoryOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export type ExtendedHttpServer = _ExtendedHttpServer;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export type HttpServerCertificateOptions = _HttpServerCertificateOptions;
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootHttpRouter` instead.
*/
export type HttpServerOptions = _HttpServerOptions;
-1
View File
@@ -21,7 +21,6 @@
*/
export * from './config';
export * from './http';
export * from './logging';
export * from './wiring';
export * from './services/implementations';
+1 -1
View File
@@ -19,7 +19,7 @@ import { CacheService } from '@backstage/backend-plugin-api';
import { DatabaseService } from '@backstage/backend-plugin-api';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { EventsService } from '@backstage/plugin-events-node';
import { ExtendedHttpServer } from '@backstage/backend-app-api';
import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { HttpRouterService } from '@backstage/backend-plugin-api';
@@ -14,12 +14,7 @@
* limitations under the License.
*/
import {
Backend,
createSpecializedBackend,
MiddlewareFactory,
ExtendedHttpServer,
} from '@backstage/backend-app-api';
import { Backend, createSpecializedBackend } from '@backstage/backend-app-api';
import {
createServiceFactory,
BackendFeature,
@@ -39,6 +34,8 @@ import {
} from '@backstage/backend-plugin-api/src/wiring/types';
import {
DefaultRootHttpRouter,
ExtendedHttpServer,
MiddlewareFactory,
createHealthRouter,
createHttpServer,
} from '@backstage/backend-defaults/rootHttpRouter';
+1
View File
@@ -99,6 +99,7 @@
},
"devDependencies": {
"@backstage/backend-app-api": "workspace:^",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@backstage/plugin-permission-backend": "workspace:^",
@@ -20,7 +20,7 @@ import {
mockServices,
startTestBackend,
} from '@backstage/backend-test-utils';
import { ExtendedHttpServer } from '@backstage/backend-app-api';
import { ExtendedHttpServer } from '@backstage/backend-defaults';
import { kubernetesObjectsProviderExtensionPoint } from '@backstage/plugin-kubernetes-node';
import { createBackendModule } from '@backstage/backend-plugin-api';
import { Entity } from '@backstage/catalog-model';
@@ -56,7 +56,7 @@ import {
kubernetesFetcherExtensionPoint,
kubernetesServiceLocatorExtensionPoint,
} from '@backstage/plugin-kubernetes-node';
import { ExtendedHttpServer } from '@backstage/backend-app-api';
import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter';
describe('API integration tests', () => {
let app: ExtendedHttpServer;
+1
View File
@@ -49,6 +49,7 @@
"devDependencies": {
"@backstage/backend-app-api": "workspace:^",
"@backstage/backend-common": "workspace:^",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@backstage/plugin-kubernetes-backend": "workspace:^",
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { ExtendedHttpServer } from '@backstage/backend-app-api';
import { ClusterDetails } from '../types';
import {
mockServices,
@@ -37,6 +36,7 @@ import { JsonObject } from '@backstage/types';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { loggerToWinstonLogger } from '@backstage/backend-common';
import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter';
describe('Pinniped - tokenCredentialRequest', () => {
let app: ExtendedHttpServer;
+1
View File
@@ -115,6 +115,7 @@
},
"devDependencies": {
"@backstage/backend-app-api": "workspace:^",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@backstage/plugin-scaffolder-node-test-utils": "workspace:^",
@@ -47,7 +47,7 @@ import {
} from '@backstage/plugin-permission-common';
import { mockCredentials, mockServices } from '@backstage/backend-test-utils';
import { AutocompleteHandler } from '@backstage/plugin-scaffolder-node/alpha';
import { MiddlewareFactory } from '@backstage/backend-app-api';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
const mockAccess = jest.fn();
+3
View File
@@ -6332,6 +6332,7 @@ __metadata:
"@azure/identity": ^4.0.0
"@backstage/backend-app-api": "workspace:^"
"@backstage/backend-common": "workspace:^"
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-client": "workspace:^"
@@ -6431,6 +6432,7 @@ __metadata:
dependencies:
"@backstage/backend-app-api": "workspace:^"
"@backstage/backend-common": "workspace:^"
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-model": "workspace:^"
@@ -7179,6 +7181,7 @@ __metadata:
dependencies:
"@backstage/backend-app-api": "workspace:^"
"@backstage/backend-common": "workspace:^"
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-tasks": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"