{"_id":"@axis-backstage-staging/plugin-readme-backend","name":"@axis-backstage-staging/plugin-readme-backend","dist-tags":{"latest":"0.4.0"},"versions":{"0.4.0":{"name":"@axis-backstage-staging/plugin-readme-backend","version":"0.4.0","main":"src/index.ts","types":"src/index.ts","license":"Apache-2.0","publishConfig":{"access":"public","main":"dist/index.cjs.js","types":"dist/index.d.ts"},"backstage":{"role":"backend-plugin"},"scripts":{"start":"backstage-cli package start","build":"backstage-cli package build","lint":"backstage-cli package lint","test":"backstage-cli package test","clean":"backstage-cli package clean","prepack":"backstage-cli package prepack","postpack":"backstage-cli package postpack"},"dependencies":{"@backstage/backend-common":"^0.20.1","@backstage/backend-plugin-api":"^0.6.9","@backstage/catalog-client":"^1.5.2","@backstage/catalog-model":"^1.4.3","@backstage/config":"^1.1.1","@backstage/integration":"^1.8.0","@backstage/plugin-permission-common":"^0.7.12","@types/express":"*","express":"^4.17.1","express-promise-router":"^4.1.0","node-fetch":"^2.6.7","winston":"^3.2.1","yn":"^4.0.0"},"devDependencies":{"@backstage/cli":"^0.25.1","@types/supertest":"^2.0.12","msw":"^1.0.0","supertest":"^6.2.4"},"_id":"@axis-backstage-staging/plugin-readme-backend@0.4.0","gitHead":"cc32eb925bac4c544aa398d29e0edced640c3264","description":"Welcome to the readme backend plugin!","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-7v5s8+ZPtFaXg8jDTw5Sj+X/PX3G5sP11YEUspEEcp2TridlDktun2ybyl9toj1mtsDImH3XsXJxY6GwzTcXnQ==","shasum":"08ed2c4e7b51e303096dff05c71345e74fe1d357","tarball":"https://registry.npmjs.org/@axis-backstage-staging/plugin-readme-backend/-/plugin-readme-backend-0.4.0.tgz","fileCount":5,"unpackedSize":23700,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAdZji1SDrTWBE5D9vIJK/tVnZJ5psuqynqM6p3MEl4BAiAqsJjesggEBMEqmJ7woWHCkJUNGU7Pz6eQ1S2AvlF7gw=="}]},"_npmUser":{"name":"glundh","email":"gustaf.lundh@axis.com"},"directories":{},"maintainers":[{"name":"glundh","email":"gustaf.lundh@axis.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-readme-backend_0.4.0_1711036856516_0.9804608017919143"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-21T16:00:56.394Z","0.4.0":"2024-03-21T16:00:56.674Z","modified":"2024-03-21T16:00:57.244Z"},"maintainers":[{"name":"glundh","email":"gustaf.lundh@axis.com"}],"description":"Welcome to the readme backend plugin!","license":"Apache-2.0","readme":"# Readme backend\n\nWelcome to the readme backend plugin!\n\nThe plugin retrieves README files from the entity source location. The corresponding frontend plugin responsible for displaying this information is the [Readme plugin](https://github.com/AxisCommunications/backstage-plugins/blob/main/plugins/readme).\n\n## Setup\n\nThe following sections will help you get the Readme Backend plugin setup and running.\n\n### Installation\n\nInstall the plugin by following the example below:\n\n```bash\n# From your Backstage root directory\nyarn --cwd packages/backend add @axis-backstage/plugin-readme-backend\n```\n\n### Integrating\n\nHere's how to get the backend plugin up and running:\n\n1. Create a new file named `packages/backend/src/plugins/readme.ts`, and add the following to it:\n\n   ```ts\n   import { createRouter } from '@axis-backstage/plugin-readme-backend';\n   import { Router } from 'express';\n   import { PluginEnvironment } from '../types';\n\n   export default async function createPlugin(\n     env: PluginEnvironment,\n   ): Promise<Router> {\n     return await createRouter({\n       logger: env.logger,\n       config: env.config,\n       reader: env.reader,\n       discovery: env.discovery,\n       tokenManager: env.tokenManager,\n     });\n   }\n   ```\n\n2. Wire this into the overall backend router by adding the following to `packages/backend/src/index.ts`:\n\n   ```ts\n   import readme from './plugins/readme';\n   ...\n\n   async function main() {\n     // Add this line under the other lines that follow the useHotMemoize pattern\n    const readmeEnv = useHotMemoize(module, () => createEnv('readme'),\n\n     // Add this under the lines that add their routers to apiRouter\n    apiRouter.use('/readme', await readme(readmeEnv));\n   }\n   ```\n\n### New Backend System\n\nThe Readme backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/). Here is how you can set it up:\n\nIn your `packages/backend/src/index.ts` make the following changes:\n\n```diff\n+ import { readmePlugin } from '@axis-backstage/readme-backend';\n\nconst backend = createBackend();\n+ backend.add(readmePlugin());\n// ... other feature additions\n\nbackend.start();\n```\n\n### Troubleshooting\n\nIf the backend fails to provide README content for an entity, it could be due to several reasons.\n\n#### No Integration Found for Entity\n\nThis error message indicates that there is no current integration with the external provider where the README file is located, such as GitHub, GitLab, or Gerrit. When the integration is missing, the backend does not have permission to access the README content.\n\nTo resolve this issue, set up the integration for the external provider where the README file is located. You can find more information about Backstage integrations in the [Backstage upstream documentation](https://backstage.io/docs/integrations/).\n\n#### Not a Valid Location for Source Target\n\nThis error means that the entity source location cannot be found or is not a valid URL. The `entity source location` is always the same directory as the catalog-info.yaml file.\n\nTo debug this error, ensure that the entity source location is valid for the current entity. You can find the entity source location in the entity's catalog-info.yaml file. See the example below:\n\n```yaml\nannotations:\n  backstage.io/source-location: url:https://github.com/AxisCommunications/backstage-plugins/blob/main/\n```\n\n#### README Not Found for Entity\n\nThis error indicates that no README, README.md, README.rst, README.txt, or README.MD file was found for that entity. To resolve this error, ensure that there is a README file located in the entity source location with one of the following formats: **md**, **rst**, or **txt**. The plugin can also handle symlinks.\n","readmeFilename":"README.md"}