diff --git a/.changeset/shiny-seahorses-do.md b/.changeset/shiny-seahorses-do.md new file mode 100644 index 0000000000..06892900bf --- /dev/null +++ b/.changeset/shiny-seahorses-do.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-badges-backend': patch +--- + +Add missing installation instructions diff --git a/plugins/badges-backend/README.md b/plugins/badges-backend/README.md index bdbfac3fa5..4f2f1ef96c 100644 --- a/plugins/badges-backend/README.md +++ b/plugins/badges-backend/README.md @@ -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