Files
backstage/plugins/lighthouse-backend
Brian Fletcher 0299dd40d6 fixes and api report
Signed-off-by: Brian Fletcher <brian@roadie.io>
2023-04-06 10:54:22 +01:00
..
2023-04-06 10:54:22 +01:00
2023-04-06 10:54:22 +01:00
2023-04-04 13:14:06 +00:00
2023-04-04 13:14:06 +00:00
2023-02-21 15:27:35 +00:00

Lighthouse Backend

Lighthouse Backend allows you to run scheduled lighthouse Tests for each Website with the annotation lighthouse.com/website-url.

Setup

  1. Install the plugin using:
# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-lighthouse-backend
  1. Create a lighthouse.ts file inside packages/backend/src/plugins/:
import { createScheduler } from '@backstage/plugin-lighthouse-backend';
import { PluginEnvironment } from '../types';
import { CatalogClient } from '@backstage/catalog-client';

export default async function createPlugin(env: PluginEnvironment) {
  const { logger, scheduler, config } = env;

  const catalogClient = new CatalogClient({
    discoveryApi: env.discovery,
  });

  await createScheduler({ logger, scheduler, config, catalogClient });
}
  1. Modify your packages/backend/src/index.ts to include:
 ...

 import { Config } from '@backstage/config';
 import app from './plugins/app';
+import lighthouse from './plugins/lighthouse';
 import scaffolder from './plugins/scaffolder';

 ...

 async function main() {

   ...

   const authEnv = useHotMemoize(module, () => createEnv('auth'));
+  const lighthouseEnv = useHotMemoize(module, () => createEnv('lighthouse'));
   const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));

   ...

   const apiRouter = Router();
   apiRouter.use('/catalog', await catalog(catalogEnv));
   apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));

+  await lighthouse(lighthouseEnv)

Configuration

You can define how often and when the scheduler should run the audits:

lighthouse:
  schedule:
    days: 1