K-Phoen / backstage-plugin-announcements

Announcements plugin for Backstage
MIT License
52 stars 30 forks source link

Announcements search issue #182

Closed ppiwow-apay closed 10 months ago

ppiwow-apay commented 1 year ago

Hi,

I have a problem with announcements search integration. It seems that search factory is not able to build index cause by lacking of API endpoint exposed by router.

I had to add this code to make it work:

export default async function createPlugin({
  logger,
  database,
  permissions,
}: PluginEnvironment): Promise<Router> {
  const announcementsContext = await buildAnnouncementsContext({
    logger: logger,
    database: database,
    permissions: permissions
  });

  const router = await createRouter(announcementsContext);

  // TODO: seems that there is an error in plugin
  router.get(
    '/',
    async (
      req,
      res,
    ) => {
        const list = await announcementsContext.persistenceContext.announcementsStore.announcements({});
        return res.json(list.results);
    },
  );
  return router;
}

plugin version: "@k-phoen/backstage-plugin-announcements-backend": "^0.2.0",