Added support for the new backend system for the entity feedback plugin

Signed-off-by: Niklas Aronsson <niklasar@axis.com>
This commit is contained in:
Niklas Aronsson
2023-06-20 21:40:56 +02:00
parent 07e8526b30
commit 5c1c10adac
9 changed files with 85 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-entity-feedback-backend': patch
---
Added support for the new backend system
+1
View File
@@ -30,6 +30,7 @@
"@backstage/plugin-auth-node": "workspace:^",
"@backstage/plugin-catalog-backend": "workspace:^",
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
"@backstage/plugin-entity-feedback-backend": "workspace:^",
"@backstage/plugin-kubernetes-backend": "workspace:^",
"@backstage/plugin-permission-backend": "workspace:^",
"@backstage/plugin-permission-common": "workspace:^",
+4
View File
@@ -30,12 +30,16 @@ import { searchModuleTechDocsCollator } from '@backstage/plugin-search-backend-m
import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
import { techdocsPlugin } from '@backstage/plugin-techdocs-backend/alpha';
import { todoPlugin } from '@backstage/plugin-todo-backend';
import { entityFeedbackPlugin } from '@backstage/plugin-entity-feedback-backend';
import { catalogModuleUnprocessedEntities } from '@backstage/plugin-catalog-backend-module-unprocessed';
const backend = createBackend();
backend.add(appPlugin({ appPackageName: 'example-app' }));
// Entity Feedback
backend.add(entityFeedbackPlugin());
// Todo
backend.add(todoPlugin());
+15
View File
@@ -48,3 +48,18 @@ async function main() {
apiRouter.use(notFoundHandler());
```
### New Backend System
The Entity Feedback backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
In your `packages/backend/src/index.ts` make the following changes:
```diff
+ import { entityFeedbackPlugin } from '@backstage/plugin-entity-feedback-backend';
const backend = createBackend();
+ backend.add(entityFeedbackPlugin());
// ... other feature additions
backend.start();
```
@@ -3,6 +3,7 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import express from 'express';
import { IdentityApi } from '@backstage/plugin-auth-node';
import { Logger } from 'winston';
@@ -12,6 +13,9 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common';
// @public (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public
export const entityFeedbackPlugin: () => BackendFeature;
// @public (undocumented)
export interface RouterOptions {
// (undocumented)
@@ -23,6 +23,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/catalog-client": "workspace:^",
"@backstage/catalog-model": "workspace:^",
"@backstage/config": "workspace:^",
@@ -20,3 +20,4 @@
* @packageDocumentation
*/
export * from './service/router';
export { entityFeedbackPlugin } from './plugin';
@@ -0,0 +1,52 @@
/*
* 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 { loggerToWinstonLogger } from '@backstage/backend-common';
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { createRouter } from './service/router';
/**
* The Entity Feedback backend plugin.
*
* @public
*/
export const entityFeedbackPlugin = createBackendPlugin({
pluginId: 'entity-feedback',
register(env) {
env.registerInit({
deps: {
discovery: coreServices.discovery,
database: coreServices.database,
identity: coreServices.identity,
logger: coreServices.logger,
httpRouter: coreServices.httpRouter,
},
async init({ database, discovery, identity, logger, httpRouter }) {
httpRouter.use(
await createRouter({
database,
discovery,
identity,
logger: loggerToWinstonLogger(logger),
}),
);
},
});
},
});
+2
View File
@@ -6288,6 +6288,7 @@ __metadata:
resolution: "@backstage/plugin-entity-feedback-backend@workspace:plugins/entity-feedback-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-client": "workspace:^"
"@backstage/catalog-model": "workspace:^"
@@ -24658,6 +24659,7 @@ __metadata:
"@backstage/plugin-auth-node": "workspace:^"
"@backstage/plugin-catalog-backend": "workspace:^"
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
"@backstage/plugin-entity-feedback-backend": "workspace:^"
"@backstage/plugin-kubernetes-backend": "workspace:^"
"@backstage/plugin-permission-backend": "workspace:^"
"@backstage/plugin-permission-common": "workspace:^"