Added support for new backend system

Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
This commit is contained in:
Rogerio Angeliski
2023-06-21 13:14:01 +00:00
parent 1050f90423
commit a8805a9a4f
9 changed files with 84 additions and 0 deletions
+18
View File
@@ -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).
+4
View File
@@ -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;
+1
View File
@@ -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:^",
+1
View File
@@ -22,3 +22,4 @@
export * from './search';
export * from './service';
export { adrPlugin } from './plugin';
+49
View File
@@ -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,
}),
);
},
});
},
});