diff --git a/.changeset/short-rabbits-roll.md b/.changeset/short-rabbits-roll.md new file mode 100644 index 0000000000..4ed0768485 --- /dev/null +++ b/.changeset/short-rabbits-roll.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-entity-feedback-backend': patch +--- + +Added support for the new backend system diff --git a/packages/backend-next/package.json b/packages/backend-next/package.json index e13078890a..bc7d5e666f 100644 --- a/packages/backend-next/package.json +++ b/packages/backend-next/package.json @@ -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:^", diff --git a/packages/backend-next/src/index.ts b/packages/backend-next/src/index.ts index cdba12e0e3..900062d61b 100644 --- a/packages/backend-next/src/index.ts +++ b/packages/backend-next/src/index.ts @@ -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()); diff --git a/plugins/entity-feedback-backend/README.md b/plugins/entity-feedback-backend/README.md index ef180dbae5..99489e28b2 100644 --- a/plugins/entity-feedback-backend/README.md +++ b/plugins/entity-feedback-backend/README.md @@ -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(); +``` diff --git a/plugins/entity-feedback-backend/api-report.md b/plugins/entity-feedback-backend/api-report.md index 3909ac3056..3e8f90220e 100644 --- a/plugins/entity-feedback-backend/api-report.md +++ b/plugins/entity-feedback-backend/api-report.md @@ -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; +// @public +export const entityFeedbackPlugin: () => BackendFeature; + // @public (undocumented) export interface RouterOptions { // (undocumented) diff --git a/plugins/entity-feedback-backend/package.json b/plugins/entity-feedback-backend/package.json index c09b011533..7cf3c40ffe 100644 --- a/plugins/entity-feedback-backend/package.json +++ b/plugins/entity-feedback-backend/package.json @@ -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:^", diff --git a/plugins/entity-feedback-backend/src/index.ts b/plugins/entity-feedback-backend/src/index.ts index b3c4139eed..74e545de04 100644 --- a/plugins/entity-feedback-backend/src/index.ts +++ b/plugins/entity-feedback-backend/src/index.ts @@ -20,3 +20,4 @@ * @packageDocumentation */ export * from './service/router'; +export { entityFeedbackPlugin } from './plugin'; diff --git a/plugins/entity-feedback-backend/src/plugin.ts b/plugins/entity-feedback-backend/src/plugin.ts new file mode 100644 index 0000000000..6a4ff442ce --- /dev/null +++ b/plugins/entity-feedback-backend/src/plugin.ts @@ -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), + }), + ); + }, + }); + }, +}); diff --git a/yarn.lock b/yarn.lock index bd1fbc6204..01cfd96a84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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:^"