Merge pull request #28271 from backstage/freben/signals-new
remove old backend system suport in the signals backend
This commit is contained in:
@@ -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/).
|
||||
@@ -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)
|
||||
|
||||
@@ -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<Router> {
|
||||
return await createRouter({
|
||||
logger: env.logger,
|
||||
events: env.events,
|
||||
identity: env.identity,
|
||||
discovery: env.discovery,
|
||||
config: env.config,
|
||||
});
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
}
|
||||
@@ -14,5 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './deprecated';
|
||||
export { signalsPlugin as default } from './plugin';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:^"
|
||||
|
||||
Reference in New Issue
Block a user