# @anakz/backstage-plugin-library-check-backend

> Backstage.io Library Check plugin backend

Latest version **0.2.0** (published 2024-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @anakz/backstage-plugin-library-check-backend
pnpm add @anakz/backstage-plugin-library-check-backend
yarn add @anakz/backstage-plugin-library-check-backend
bun add @anakz/backstage-plugin-library-check-backend
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-04-30 |
| First published | 2024-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 28 |
| Unpacked size | 181.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 35 |
| Maintainers | accezar |
| Keywords | backstage, plugin, backend, backstage.io |

## Links

- npm: https://www.npmjs.com/package/@anakz/backstage-plugin-library-check-backend
- Repository: https://github.com/anakzr/backstage-plugin-library-check
- Issues: https://github.com/anakzr/backstage-plugin-library-check/issues
- npm.io page: https://npm.io/package/@anakz/backstage-plugin-library-check-backend

## Dependencies (28)

- [yn](https://npm.io/package/yn.md) ^4.0.0
- [knex](https://npm.io/package/knex.md) ^3.0.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [axios](https://npm.io/package/axios.md) ^1.6.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [semver](https://npm.io/package/semver.md) ^7.6.0
- [xml2js](https://npm.io/package/xml2js.md) ^0.6.2
- [express](https://npm.io/package/express.md) ^4.18.1
- [p-limit](https://npm.io/package/p-limit.md) ^3.0.2
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [gradle-to-js](https://npm.io/package/gradle-to-js.md) ^2.0.1
- [@octokit/rest](https://npm.io/package/@octokit/rest.md) ^20.0.2
- [child-process](https://npm.io/package/child-process.md) ^1.0.2
- [git-url-parse](https://npm.io/package/git-url-parse.md) ^11.4.4
- [@types/express](https://npm.io/package/@types/express.md) *
- [@backstage/config](https://npm.io/package/@backstage/config.md) ^1.1.1
- [@backstage/errors](https://npm.io/package/@backstage/errors.md) ^1.2.4
- [pip-requirements-js](https://npm.io/package/pip-requirements-js.md) ^0.2.1
- [@backstage/integration](https://npm.io/package/@backstage/integration.md) ^1.9.0
- [express-promise-router](https://npm.io/package/express-promise-router.md) ^4.1.0
- [@backstage/backend-tasks](https://npm.io/package/@backstage/backend-tasks.md) ^0.5.17
- [@backstage/catalog-model](https://npm.io/package/@backstage/catalog-model.md) ^1.4.4
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.21.2
- [@backstage/backend-plugin-api](https://npm.io/package/@backstage/backend-plugin-api.md) ^0.6.12
- [@backstage/backend-test-utils](https://npm.io/package/@backstage/backend-test-utils.md) ^0.3.3
- [@backstage/plugin-catalog-node](https://npm.io/package/@backstage/plugin-catalog-node.md) ^1.7.2
- [@backstage/plugin-catalog-common](https://npm.io/package/@backstage/plugin-catalog-common.md) ^1.0.21

## Recent versions

- 0.2.0 (latest) — 2024-04-30
- 0.1.0 — 2024-04-02
- 0.0.3 — 2024-03-20
- 0.0.2 — 2024-03-10
- 0.0.1 — 2024-03-10

## README

# Library Check Backend

Welcome to the library-check-backend backend plugin!

_This plugin was created through the Backstage CLI_


### Setup instructions:

Add the plugin to your backend app:

```bash
cd packages/backend && yarn add @anakz/backstage-plugin-library-check-backend
```

Create new file at packages/backend/src/plugins/libraryCheck.ts:

```ts

// packages/backend/src/plugins/libraryCheck.ts

import { PluginEnvironment } from '../types';
import { Router } from 'express';
import {
  DatabaseLibraryCheckStore,
  createRouter,
} from '@anakz/backstage-plugin-library-check-backend';

export default async function createPlugin({
  logger,
  database,
  config,
}: PluginEnvironment): Promise<Router> {
  const db = await DatabaseLibraryCheckStore.create({
    database: database,
  });
  return await createRouter({
    logger,
    database: db,
    config,
  });
}
```

Define the schedules for the plugin processor and provider on packages/backend/src/plugins/catalog.ts

```ts

// packages/backend/src/plugins/catalog.ts

// ...
builder.addEntityProvider(

    // add a new provider entry, configure the schedule frequency as you wish
    // initialDelay must be up to 15s to avoid conflicts

    LibraryCheckProvider.fromConfig({
      config: env.config,
      envId: 'production',
      logger: env.logger,
      discovery: env.discovery,
      schedule: env.scheduler.createScheduledTaskRunner({
        initialDelay: {
          seconds: 15,
        },
        frequency: {
          minutes: 60,
        },
        timeout: {
          minutes: 1,
        },
      }),
    }),

    // ...
)

// Add the new processor entries, and try to declare the LibraryCheckUpdater as the last in order.

  builder.addProcessor(
    // ...

    LibraryCheckProcessor.fromConfig(env.config, {
      discoveryService: env.discovery,
      reader: env.reader,
      logger: env.logger,
    }),

    // Other processors...
    
    LibraryCheckUpdaterProcessor.fromConfig(env.config, {
      discoveryService: env.discovery,
      reader: env.reader,
      logger: env.logger,
    }),

    // ...
  );


```

Now add the plugin to your packages/backend/src/index.ts:

```ts
import libraryCheck from './plugins/libraryCheck';

// ...
const libraryCheckEnv = useHotMemoize(module, () => createEnv('libraryCheck'));

// ...
  apiRouter.use('/library-check', await libraryCheck(libraryCheckEnv));
```

---
_Source: https://npm.io/package/@anakz/backstage-plugin-library-check-backend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
