reafactor: deprecate legacy handlers and context

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-05-20 13:31:47 +02:00
parent 40ae05f3c6
commit 3bd04bb3ac
9 changed files with 16 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': patch
---
We are deprecating the legacy router handlers and contexts in preparation for the new backend system stable release.
+2 -2
View File
@@ -5,14 +5,14 @@
```ts
import { Duration } from 'luxon';
// @alpha
// @alpha @deprecated
export interface Context {
readonly abortSignal: AbortSignal;
readonly deadline: Date | undefined;
value<T = unknown>(key: string): T | undefined;
}
// @alpha
// @alpha @deprecated
export class Contexts {
static root(): Context;
static withAbort(
+3 -3
View File
@@ -309,7 +309,7 @@ export function dropDatabase(
...databaseNames: string[]
): Promise<void>;
// @public
// @public @deprecated
export function errorHandler(
options?: ErrorHandlerOptions,
): ErrorRequestHandler;
@@ -532,7 +532,7 @@ export class HarnessUrlReader implements UrlReader {
toString(): string;
}
// @public
// @public @deprecated
export const HostDiscovery: typeof HostDiscovery_2;
// @public @deprecated (undocumented)
@@ -733,7 +733,7 @@ export function redactWinstonLogLine(
info: winston.Logform.TransformableInfo,
): winston.Logform.TransformableInfo;
// @public
// @public @deprecated
export function requestLoggingHandler(logger?: LoggerService): RequestHandler;
// @public
@@ -24,6 +24,7 @@ import { ValueContext } from './ValueContext';
* Common context decorators.
*
* @alpha
* @deprecated This class is not used in the new Backend system, so it is going to be removed in a near future.
*/
export class Contexts {
/**
@@ -19,6 +19,7 @@
* to pass along scoped information and abort signals.
*
* @alpha
* @deprecated This type is not used in the new Backend system, so it is going to be removed in a near future.
*/
export interface Context {
/**
@@ -27,6 +27,7 @@ export type { DiscoveryService as PluginEndpointDiscovery } from '@backstage/bac
* resolved to the same host, so there won't be any balancing of internal traffic.
*
* @public
* @deprecated Please import from `@backstage/backend-defaults/discovery` instead.
*/
export const HostDiscovery = _HostDiscovery;
@@ -61,6 +61,7 @@ export type ErrorHandlerOptions = {
*
* @public
* @returns An Express error request handler
* @deprecated Use {@link @backstage/backend-app-api#MiddlewareFactory.create.error} instead
*/
export function errorHandler(
options: ErrorHandlerOptions = {},
@@ -26,6 +26,7 @@ import { ConfigReader } from '@backstage/config';
* @public
* @param logger - An optional logger to use. If not specified, the root logger will be used.
* @returns An Express request handler
* @deprecated @deprecated Use {@link @backstage/backend-app-api#MiddlewareFactory.create.logging} instead
*/
export function requestLoggingHandler(logger?: LoggerService): RequestHandler {
return MiddlewareFactory.create({
@@ -481,6 +481,7 @@ export function createPermissionIntegrationRouter<
},
);
// TODO(belugas): Remove this when dropping support to the legacy backend system because setting the error handler manually is no logger required in the new system.
router.use(errorHandler());
return router;