Files
backstage/plugins/bazaar-backend
Dominik Schwank 5b7cd5580d fix: move backend-test-utils to devDependencies
The backend-test-utils should only be used as devDependencies. Otherwise they might cause trouble
while installing related plugins in docker images.

Signed-off-by: Dominik Schwank <dominik.schwank@sda.se>
2023-02-09 17:50:35 +01:00
..
2022-12-03 16:24:57 +01:00
2023-02-07 15:03:45 +00:00

Bazaar Backend

Welcome to the Bazaar backend plugin!

Installation

Install the package

# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-bazaar-backend

Adding the plugin to your packages/backend

You'll need to add the plugin to the router in your backend package. You can do this by creating a file called packages/backend/src/plugins/bazaar.ts

import { PluginEnvironment } from '../types';
import { createRouter } from '@backstage/plugin-bazaar-backend';
import { Router } from 'express';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter({
    logger: env.logger,
    config: env.config,
    database: env.database,
    identity: env.identity,
  });
}

With the bazaar.ts router setup in place, add the router to packages/backend/src/index.ts:

+ import bazaar from './plugins/bazaar';

async function main() {
  ...
  const createEnv = makeCreateEnv(config);

  const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
+    const bazaarEnv = useHotMemoize(module, () => createEnv('bazaar'));

  const apiRouter = Router();
+  apiRouter.use('/bazaar', await bazaar(bazaarEnv));
  ...
  apiRouter.use(notFoundHandler());