remove old backend system suport in the signals backend

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2024-12-21 22:04:10 +01:00
parent 6b92433d5e
commit f59ea1d40d
13 changed files with 20 additions and 141 deletions
+1 -2
View File
@@ -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",
-32
View File
@@ -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<express.Router>;
// @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;
-60
View File
@@ -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<express.Router> {
return _createRouter({
...options,
...createLegacyAuthAdapters(options),
});
}
-1
View File
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export * from './deprecated';
export { signalsPlugin as default } from './plugin';
+2 -1
View File
@@ -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
@@ -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', () => {
@@ -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() {
@@ -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());
@@ -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;
}