Merge pull request #26058 from backstage/jhaals/app-backend-cleanup

app-backend: Deprecate createRouter
This commit is contained in:
Johan Haals
2024-08-16 17:12:37 +02:00
committed by GitHub
3 changed files with 27 additions and 15 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-backend': patch
---
Deprecate `createRouter` and its options in favour of the new backend system.
+6 -6
View File
@@ -4,24 +4,24 @@
```ts
import { AuthService } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import { DatabaseService } from '@backstage/backend-plugin-api';
import express from 'express';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PluginDatabaseManager } from '@backstage/backend-common';
import { RootConfigService } from '@backstage/backend-plugin-api';
// @public (undocumented)
// @public @deprecated (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
// @public @deprecated (undocumented)
export interface RouterOptions {
appPackageName: string;
// (undocumented)
auth?: AuthService;
// (undocumented)
config: Config;
database?: PluginDatabaseManager;
config: RootConfigService;
database?: DatabaseService;
disableConfigInjection?: boolean;
// (undocumented)
httpAuth?: HttpAuthService;
+16 -9
View File
@@ -14,12 +14,13 @@
* limitations under the License.
*/
import { notFoundHandler } from '@backstage/backend-common';
import {
notFoundHandler,
PluginDatabaseManager,
} from '@backstage/backend-common';
import { resolvePackagePath } from '@backstage/backend-plugin-api';
import { AppConfig, Config } from '@backstage/config';
DatabaseService,
resolvePackagePath,
RootConfigService,
} from '@backstage/backend-plugin-api';
import { AppConfig } from '@backstage/config';
import helmet from 'helmet';
import express from 'express';
import Router from 'express-promise-router';
@@ -47,9 +48,12 @@ import { AuthenticationError } from '@backstage/errors';
// express uses mime v1 while we only have types for mime v2
type Mime = { lookup(arg0: string): string };
/** @public */
/**
* @public
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*/
export interface RouterOptions {
config: Config;
config: RootConfigService;
logger: LoggerService;
auth?: AuthService;
httpAuth?: HttpAuthService;
@@ -59,7 +63,7 @@ export interface RouterOptions {
*
* This is a built-in alternative to using a `staticFallbackHandler`.
*/
database?: PluginDatabaseManager;
database?: DatabaseService;
/**
* The name of the app package that content should be served from. The same app package should be
@@ -102,7 +106,10 @@ export interface RouterOptions {
schema?: ConfigSchema;
}
/** @public */
/**
* @public
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*/
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {