remove http interface
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
+31
-17
@@ -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<typeof createBackendPlugin>;
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
-34
@@ -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;
|
||||
}
|
||||
+2
-9
@@ -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;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user