diff --git a/.changeset/dry-hounds-study.md b/.changeset/dry-hounds-study.md new file mode 100644 index 0000000000..0d58431439 --- /dev/null +++ b/.changeset/dry-hounds-study.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-signals-backend': minor +--- + +Removed support for the old backend system. If you were using the old `createRouter` export, please migrate to [the new backend system](https://backstage.io/docs/backend-system/). diff --git a/packages/backend-legacy/src/index.ts b/packages/backend-legacy/src/index.ts index 8ef969ff2b..c883603efb 100644 --- a/packages/backend-legacy/src/index.ts +++ b/packages/backend-legacy/src/index.ts @@ -47,7 +47,6 @@ import search from './plugins/search'; import techdocs from './plugins/techdocs'; import app from './plugins/app'; import permission from './plugins/permission'; -import signals from './plugins/signals'; import { PluginEnvironment } from './types'; import { ServerPermissionClient } from '@backstage/plugin-permission-node'; import { DefaultIdentityClient } from '@backstage/plugin-auth-node'; @@ -137,7 +136,6 @@ async function main() { const appEnv = useHotMemoize(module, () => createEnv('app')); const permissionEnv = useHotMemoize(module, () => createEnv('permission')); const eventsEnv = useHotMemoize(module, () => createEnv('events')); - const signalsEnv = useHotMemoize(module, () => createEnv('signals')); const apiRouter = Router(); apiRouter.use('/catalog', await catalog(catalogEnv)); @@ -149,7 +147,6 @@ async function main() { apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv)); apiRouter.use('/proxy', await proxy(proxyEnv)); apiRouter.use('/permission', await permission(permissionEnv)); - apiRouter.use('/signals', await signals(signalsEnv)); apiRouter.use(notFoundHandler()); const service = createServiceBuilder(module) diff --git a/packages/backend-legacy/src/plugins/signals.ts b/packages/backend-legacy/src/plugins/signals.ts deleted file mode 100644 index 33b1af5edf..0000000000 --- a/packages/backend-legacy/src/plugins/signals.ts +++ /dev/null @@ -1,30 +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 { Router } from 'express'; -import { createRouter } from '@backstage/plugin-signals-backend'; -import { PluginEnvironment } from '../types'; - -export default async function createPlugin( - env: PluginEnvironment, -): Promise { - return await createRouter({ - logger: env.logger, - events: env.events, - identity: env.identity, - discovery: env.discovery, - config: env.config, - }); -} diff --git a/plugins/signals-backend/package.json b/plugins/signals-backend/package.json index 9a10b0e43b..8f26a4dea8 100644 --- a/plugins/signals-backend/package.json +++ b/plugins/signals-backend/package.json @@ -37,14 +37,12 @@ "test": "backstage-cli package test" }, "dependencies": { - "@backstage/backend-common": "^0.25.0", "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/plugin-auth-node": "workspace:^", "@backstage/plugin-events-node": "workspace:^", "@backstage/plugin-signals-node": "workspace:^", "@backstage/types": "workspace:^", - "@types/express": "^4.17.6", "express": "^4.17.1", "express-promise-router": "^4.1.0", "http-proxy-middleware": "^2.0.0", @@ -60,6 +58,7 @@ "@backstage/plugin-auth-backend": "workspace:^", "@backstage/plugin-auth-backend-module-guest-provider": "workspace:^", "@backstage/plugin-events-backend": "workspace:^", + "@types/express": "^4.17.6", "@types/supertest": "^2.0.8", "@types/ws": "^8.5.10", "msw": "^1.0.0", diff --git a/plugins/signals-backend/report.api.md b/plugins/signals-backend/report.api.md index 10f74ba37e..2b27ef2b3c 100644 --- a/plugins/signals-backend/report.api.md +++ b/plugins/signals-backend/report.api.md @@ -3,39 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { AuthService } from '@backstage/backend-plugin-api'; import { BackendFeature } from '@backstage/backend-plugin-api'; -import { Config } from '@backstage/config'; -import { DiscoveryService } from '@backstage/backend-plugin-api'; -import { EventsService } from '@backstage/plugin-events-node'; -import express from 'express'; -import { IdentityApi } from '@backstage/plugin-auth-node'; -import { LifecycleService } from '@backstage/backend-plugin-api'; -import { LoggerService } from '@backstage/backend-plugin-api'; -import { UserInfoService } from '@backstage/backend-plugin-api'; - -// @public @deprecated (undocumented) -export function createRouter(options: RouterOptions): Promise; - -// @public @deprecated (undocumented) -export interface RouterOptions { - // (undocumented) - auth?: AuthService; - // (undocumented) - config: Config; - // (undocumented) - discovery: DiscoveryService; - // (undocumented) - events: EventsService; - // (undocumented) - identity?: IdentityApi; - // (undocumented) - lifecycle?: LifecycleService; - // (undocumented) - logger: LoggerService; - // (undocumented) - userInfo?: UserInfoService; -} // @public const signalsPlugin: BackendFeature; diff --git a/plugins/signals-backend/src/deprecated.ts b/plugins/signals-backend/src/deprecated.ts deleted file mode 100644 index d33c9a06b9..0000000000 --- a/plugins/signals-backend/src/deprecated.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2024 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 express from 'express'; - -import { Config } from '@backstage/config'; -import { - AuthService, - DiscoveryService, - LifecycleService, - LoggerService, - UserInfoService, -} from '@backstage/backend-plugin-api'; -import { createLegacyAuthAdapters } from '@backstage/backend-common'; - -import { IdentityApi } from '@backstage/plugin-auth-node'; -import { EventsService } from '@backstage/plugin-events-node'; - -import { createRouter as _createRouter } from './service/router'; - -/** - * @public - * @deprecated Please migrate to the new backend system as this will be removed in the future. - */ -export interface RouterOptions { - logger: LoggerService; - events: EventsService; - identity?: IdentityApi; - discovery: DiscoveryService; - config: Config; - lifecycle?: LifecycleService; - auth?: AuthService; - userInfo?: UserInfoService; -} - -/** - * @public - * @deprecated Please migrate to the new backend system as this will be removed in the future. - */ -export async function createRouter( - options: RouterOptions, -): Promise { - return _createRouter({ - ...options, - ...createLegacyAuthAdapters(options), - }); -} diff --git a/plugins/signals-backend/src/index.ts b/plugins/signals-backend/src/index.ts index c852c81518..c5b3fe692a 100644 --- a/plugins/signals-backend/src/index.ts +++ b/plugins/signals-backend/src/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export * from './deprecated'; export { signalsPlugin as default } from './plugin'; diff --git a/plugins/signals-backend/src/plugin.ts b/plugins/signals-backend/src/plugin.ts index 3ca10f46d1..f01777b4fc 100644 --- a/plugins/signals-backend/src/plugin.ts +++ b/plugins/signals-backend/src/plugin.ts @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { coreServices, createBackendPlugin, } from '@backstage/backend-plugin-api'; -import { createRouter } from './deprecated'; import { eventsServiceRef } from '@backstage/plugin-events-node'; +import { createRouter } from './service/router'; /** * Signals backend plugin diff --git a/plugins/signals-backend/src/service/SignalManager.test.ts b/plugins/signals-backend/src/service/SignalManager.test.ts index eccc715d1b..642c00a7d7 100644 --- a/plugins/signals-backend/src/service/SignalManager.test.ts +++ b/plugins/signals-backend/src/service/SignalManager.test.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { WebSocket } from 'ws'; import { EventsServiceSubscribeOptions } from '@backstage/plugin-events-node'; import { SignalManager } from './SignalManager'; -import { ConfigReader } from '@backstage/config'; import { mockServices } from '@backstage/backend-test-utils'; class MockWebSocket { @@ -70,15 +70,15 @@ describe('SignalManager', () => { }; const shutdownHooks: Function[] = []; - const mockLifecycle = { + const mockLifecycle = mockServices.lifecycle.mock({ addShutdownHook: (hook: Function) => shutdownHooks.push(hook), - }; + }); const manager = SignalManager.create({ events: mockEvents, logger: mockServices.logger.mock(), - config: new ConfigReader({}), - lifecycle: mockLifecycle as any, + config: mockServices.rootConfig(), + lifecycle: mockLifecycle, }); it('should close all connections when server is closed', () => { diff --git a/plugins/signals-backend/src/service/SignalManager.ts b/plugins/signals-backend/src/service/SignalManager.ts index bf20d6a8c4..ec9cb57900 100644 --- a/plugins/signals-backend/src/service/SignalManager.ts +++ b/plugins/signals-backend/src/service/SignalManager.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { EventParams, EventsService } from '@backstage/plugin-events-node'; import { SignalPayload } from '@backstage/plugin-signals-node'; import crypto from 'crypto'; @@ -45,7 +46,7 @@ export type SignalManagerOptions = { events: EventsService; config: Config; logger: LoggerService; - lifecycle?: LifecycleService; + lifecycle: LifecycleService; }; /** @internal */ @@ -79,7 +80,7 @@ export class SignalManager { this.onEventBrokerEvent(params.eventPayload as SignalPayload), }); - options.lifecycle?.addShutdownHook(() => this.onShutdown()); + options.lifecycle.addShutdownHook(() => this.onShutdown()); } private ping() { diff --git a/plugins/signals-backend/src/service/router.test.ts b/plugins/signals-backend/src/service/router.test.ts index acc49739b8..0138a1a5d3 100644 --- a/plugins/signals-backend/src/service/router.test.ts +++ b/plugins/signals-backend/src/service/router.test.ts @@ -16,9 +16,7 @@ import express from 'express'; import request from 'supertest'; - import { createRouter } from './router'; -import { ConfigReader } from '@backstage/config'; import { mockErrorHandler, mockServices } from '@backstage/backend-test-utils'; const eventsServiceMock = mockServices.events.mock(); @@ -36,7 +34,8 @@ describe('createRouter', () => { events: eventsServiceMock, discovery, userInfo, - config: new ConfigReader({}), + config: mockServices.rootConfig(), + lifecycle: mockServices.lifecycle.mock(), auth: mockServices.auth(), }); app = express().use(router).use(mockErrorHandler()); diff --git a/plugins/signals-backend/src/service/router.ts b/plugins/signals-backend/src/service/router.ts index 0633e5fb8d..eb1c24f383 100644 --- a/plugins/signals-backend/src/service/router.ts +++ b/plugins/signals-backend/src/service/router.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import express, { NextFunction, Request, Response } from 'express'; import Router from 'express-promise-router'; import { @@ -36,7 +37,7 @@ export interface RouterOptions { events: EventsService; discovery: DiscoveryService; config: Config; - lifecycle?: LifecycleService; + lifecycle: LifecycleService; userInfo: UserInfoService; auth: AuthService; } diff --git a/yarn.lock b/yarn.lock index e7583ddd90..66f1511bd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7928,7 +7928,6 @@ __metadata: version: 0.0.0-use.local resolution: "@backstage/plugin-signals-backend@workspace:plugins/signals-backend" dependencies: - "@backstage/backend-common": ^0.25.0 "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^"