Merge pull request #12363 from steinwelberg/improve-installation-docs-plugins-badges-backend

Add missing installation steps to plugin-badges-backend
This commit is contained in:
Fredrik Adelöw
2022-07-04 15:16:17 +02:00
committed by GitHub
2 changed files with 41 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-badges-backend': patch
---
Add missing installation instructions
+36 -2
View File
@@ -11,8 +11,14 @@ endpoint.
## Installation
Install the `@backstage/plugin-badges-backend` package in your backend package,
and then integrate the plugin using the following default setup for
Install the `@backstage/plugin-badges-backend` package in your backend package:
```bash
# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-badges-backend
```
Add the plugin using the following default setup for
`src/plugins/badges.ts`:
```ts
@@ -39,6 +45,34 @@ the badges-backend `createRouter()` to forward to the default badge builder. To
customize the available badges, provide a custom set of badge factories. See
further down for an example of a custom badge factories function.
Finally, you have to make the following changes in `src/index.ts`:
```ts
// 1. import the plugin
import badges from './plugins/badges';
...
const config = await loadBackendConfig({
argv: process.argv,
logger: rootLogger,
});
const createEnv = makeCreateEnv(config);
...
// 2. Create a PluginEnvironment for the Badges plugin
const badgesEnv = useHotMemoize(module, () => createEnv('badges'));
...
const apiRouter = Router();
...
// 3. Register the badges plugin in the router
apiRouter.use('/badges', await badges(badgesEnv));
...
apiRouter.use(notFoundHandler());
```
## Badge builder
Badges are created by classes implementing the `BadgeBuilder` type. The default