From 95fc28931dcd7dbc60690cd0fe2a0830c21280f7 Mon Sep 17 00:00:00 2001 From: aramissennyeydd Date: Mon, 10 Nov 2025 09:50:07 -0500 Subject: [PATCH] remove http interface Signed-off-by: aramissennyeydd --- .../RootSystemMetadataService.test.ts | 48 ++++++++++++------- .../lib/createSystemMetadataRouter.ts | 34 ------------- .../rootSystemMetadataServiceFactory.ts | 11 +---- 3 files changed, 33 insertions(+), 60 deletions(-) delete mode 100644 packages/backend-defaults/src/entrypoints/rootSystemMetadata/lib/createSystemMetadataRouter.ts diff --git a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/RootSystemMetadataService.test.ts b/packages/backend-defaults/src/entrypoints/rootSystemMetadata/RootSystemMetadataService.test.ts index 12f1cc586a..b2d7b52083 100644 --- a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/RootSystemMetadataService.test.ts +++ b/packages/backend-defaults/src/entrypoints/rootSystemMetadata/RootSystemMetadataService.test.ts @@ -22,26 +22,39 @@ import { createServiceFactory, } from '@backstage/backend-plugin-api'; import { createBackend } from '../../CreateBackend'; +import { Backend } from '@backstage/backend-app-api'; +import Router from 'express-promise-router'; describe('SystemMetadataService', () => { describe('returns plugins from config', () => { let port: number; - let testPlugin: ReturnType; + let instance: Backend; beforeEach(async () => { port = await getPort(); - testPlugin = createBackendPlugin({ - pluginId: 'test-plugin', - register(reg) { - reg.registerInit({ - deps: {}, - init: async () => {}, - }); - }, - }); + instance = createBackend(); + instance.add( + createBackendPlugin({ + pluginId: 'test-plugin', + register(reg) { + reg.registerInit({ + deps: { + systemMetadata: coreServices.rootSystemMetadata, + rootHttpRouter: coreServices.rootHttpRouter, + }, + init: async ({ systemMetadata, rootHttpRouter }) => { + const router = Router(); + router.use('/plugins', async (_, res) => { + res.json(await systemMetadata.getInstalledPlugins()); + }); + rootHttpRouter.use('/systemMetadata', router); + }, + }); + }, + }), + ); }); it('should list all known instances', async () => { - const instance = createBackend(); instance.add( mockServices.rootConfig.factory({ data: { @@ -54,11 +67,10 @@ describe('SystemMetadataService', () => { }, }), ); - instance.add(testPlugin); await instance.start(); const instanceResponse = await fetch( - `http://localhost:${port}/.backstage/systemMetadata/v1/plugins/installed`, + `http://localhost:${port}/systemMetadata/plugins`, ); expect(instanceResponse.status).toBe(200); @@ -91,13 +103,11 @@ describe('SystemMetadataService', () => { deps: {}, factory: () => config, }); - const instance = createBackend(); instance.add(configFactory); - instance.add(testPlugin); await instance.start(); const instance1Response = await fetch( - `http://localhost:${port}/.backstage/systemMetadata/v1/plugins/installed`, + `http://localhost:${port}/systemMetadata/plugins`, ); expect(instance1Response.status).toBe(200); @@ -133,7 +143,7 @@ describe('SystemMetadataService', () => { }); const responseAfterUpdate = await fetch( - `http://localhost:${port}/.backstage/systemMetadata/v1/plugins/installed`, + `http://localhost:${port}/systemMetadata/plugins`, ); expect(responseAfterUpdate.status).toBe(200); @@ -158,5 +168,9 @@ describe('SystemMetadataService', () => { }, ]); }); + + afterEach(async () => { + await instance.stop(); + }); }); }); diff --git a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/lib/createSystemMetadataRouter.ts b/packages/backend-defaults/src/entrypoints/rootSystemMetadata/lib/createSystemMetadataRouter.ts deleted file mode 100644 index 6ef87309f7..0000000000 --- a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/lib/createSystemMetadataRouter.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2025 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 { LoggerService } from '@backstage/backend-plugin-api'; -import type { RootSystemMetadataService } from '@backstage/backend-plugin-api'; -import Router from 'express-promise-router'; - -export async function createSystemMetadataRouter(options: { - logger: LoggerService; - systemMetadata: RootSystemMetadataService; -}) { - const { systemMetadata } = options; - - const router = Router(); - - router.get('/plugins/installed', async (_, res) => { - res.json(await systemMetadata.getInstalledPlugins()); - }); - - return router; -} diff --git a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.ts b/packages/backend-defaults/src/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.ts index 0baa41be07..62cd8bf3bc 100644 --- a/packages/backend-defaults/src/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.ts +++ b/packages/backend-defaults/src/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.ts @@ -19,7 +19,6 @@ import { createServiceFactory, } from '@backstage/backend-plugin-api'; import { DefaultRootSystemMetadataService } from './lib/DefaultRootSystemMetadataService'; -import { createSystemMetadataRouter } from './lib/createSystemMetadataRouter'; /** * Metadata about an entire Backstage system, a collection of Backstage instances. @@ -31,19 +30,13 @@ export const rootSystemMetadataServiceFactory = createServiceFactory({ deps: { logger: coreServices.rootLogger, config: coreServices.rootConfig, - httpRouter: coreServices.rootHttpRouter, instanceMetadata: coreServices.rootInstanceMetadata, }, - async factory({ logger, config, httpRouter, instanceMetadata }) { - const systemMetadata = DefaultRootSystemMetadataService.create({ + async factory({ logger, config, instanceMetadata }) { + return DefaultRootSystemMetadataService.create({ logger, config, instanceMetadata, }); - - const router = await createSystemMetadataRouter({ systemMetadata, logger }); - - httpRouter.use('/.backstage/systemMetadata/v1', router); - return systemMetadata; }, });