Add missing installation steps

Signed-off-by: Stein Welberg <stein.welberg@onewelcome.com>
This commit is contained in:
Stein Welberg
2022-06-30 17:30:55 +02:00
parent badefbfd2a
commit 58fd5ee9d5
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. importing 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