add example router

Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
aramissennyeydd
2025-11-10 10:08:41 -05:00
parent 9a5833c99a
commit 1d124c3435
3 changed files with 51 additions and 1 deletions
+2 -1
View File
@@ -69,7 +69,8 @@
"@opentelemetry/auto-instrumentations-node": "^0.61.0",
"@opentelemetry/exporter-prometheus": "^0.54.0",
"@opentelemetry/sdk-node": "^0.54.0",
"example-app": "link:../app"
"example-app": "link:../app",
"express-promise-router": "^4.1.0"
},
"devDependencies": {
"@backstage/cli": "workspace:^"
+1
View File
@@ -69,6 +69,7 @@ backend.add(searchLoader);
backend.add(import('@backstage/plugin-techdocs-backend'));
backend.add(import('@backstage/plugin-signals-backend'));
backend.add(import('@backstage/plugin-notifications-backend'));
backend.add(import('./systemMetadataPlugin'));
backend.add(import('@backstage/plugin-events-backend-module-google-pubsub'));
backend.add(import('@backstage/plugin-mcp-actions-backend'));
@@ -0,0 +1,48 @@
/*
* 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 {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import Router from 'express-promise-router';
/**
* Example plugin that shows how to reveal all installed plugins with the
* system metadata API.
*/
export default createBackendPlugin({
pluginId: 'system-metadata-router',
register: reg => {
reg.registerInit({
deps: {
systemMetadata: coreServices.rootSystemMetadata,
rootHttpRouter: coreServices.rootHttpRouter,
},
async init({ systemMetadata, rootHttpRouter }) {
const router = Router();
router.get('/plugins', async (_, res) => {
const plugins = (await systemMetadata.getInstalledPlugins()).toSorted(
(a, b) => a.pluginId.localeCompare(b.pluginId),
);
res.json(plugins);
});
rootHttpRouter.use('/.backstage/systemMetadata', router);
},
});
},
});