Added support for new backend system
Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-adr-backend': patch
|
||||
---
|
||||
|
||||
Added support for the [new backend system](https://backstage.io/docs/backend-system/)
|
||||
@@ -27,6 +27,7 @@
|
||||
"dependencies": {
|
||||
"@backstage/backend-defaults": "workspace:^",
|
||||
"@backstage/backend-tasks": "workspace:^",
|
||||
"@backstage/plugin-adr-backend": "workspace:^",
|
||||
"@backstage/plugin-app-backend": "workspace:^",
|
||||
"@backstage/plugin-auth-node": "workspace:^",
|
||||
"@backstage/plugin-azure-devops-backend": "workspace:^",
|
||||
|
||||
@@ -37,6 +37,7 @@ import { azureDevOpsPlugin } from '@backstage/plugin-azure-devops-backend';
|
||||
import { linguistPlugin } from '@backstage/plugin-linguist-backend';
|
||||
import { devtoolsPlugin } from '@backstage/plugin-devtools-backend';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
import { adrPlugin } from '@backstage/plugin-adr-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
@@ -73,6 +74,8 @@ backend.add(
|
||||
// Todo
|
||||
backend.add(todoPlugin());
|
||||
|
||||
backend.add(adrPlugin());
|
||||
|
||||
// Techdocs
|
||||
backend.add(techdocsPlugin());
|
||||
|
||||
|
||||
@@ -58,6 +58,24 @@ async function main() {
|
||||
|
||||
4. Now run `yarn start-backend` from the repo root
|
||||
|
||||
### New Backend System
|
||||
|
||||
The ADR 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 { adrPlugin } from '@backstage/plugin-adr-backend';
|
||||
const backend = createBackend();
|
||||
|
||||
+ backend.add(adrPlugin());
|
||||
|
||||
// ... other feature additions
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
## Indexing ADR documents for search
|
||||
|
||||
Before you are able to start indexing ADR documents to search, you need to go through the [search getting started guide](https://backstage.io/docs/features/search/getting-started).
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { AdrDocument } from '@backstage/plugin-adr-common';
|
||||
import { AdrFilePathFilterFn } from '@backstage/plugin-adr-common';
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { CacheClient } from '@backstage/backend-common';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { Config } from '@backstage/config';
|
||||
@@ -43,6 +44,9 @@ export type AdrParserContext = {
|
||||
path: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const adrPlugin: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export type AdrRouterOptions = {
|
||||
reader: UrlReader;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/catalog-client": "workspace:^",
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
|
||||
export * from './search';
|
||||
export * from './service';
|
||||
export { adrPlugin } from './plugin';
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* ADR backend plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const adrPlugin = createBackendPlugin({
|
||||
pluginId: 'adr',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
reader: coreServices.urlReader,
|
||||
cache: coreServices.cache,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
},
|
||||
async init({ httpRouter, logger, reader, cache }) {
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
reader,
|
||||
cacheClient: cache,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -4576,6 +4576,7 @@ __metadata:
|
||||
resolution: "@backstage/plugin-adr-backend@workspace:plugins/adr-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/catalog-client": "workspace:^"
|
||||
"@backstage/catalog-model": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
@@ -24964,6 +24965,7 @@ __metadata:
|
||||
"@backstage/backend-defaults": "workspace:^"
|
||||
"@backstage/backend-tasks": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/plugin-adr-backend": "workspace:^"
|
||||
"@backstage/plugin-app-backend": "workspace:^"
|
||||
"@backstage/plugin-auth-node": "workspace:^"
|
||||
"@backstage/plugin-azure-devops-backend": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user