# @hashicorp/plugin-hcp-consul-backend

> A backend for HCP Consul, this plugin exposes a services with routes that are used by the `@hashicorp/plugin-hcp-consul` plugin to query HCP Consul overview and service instances using HCP Consul Central public APIs.

Latest version **0.1.3** (published 2024-01-05) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @hashicorp/plugin-hcp-consul-backend
pnpm add @hashicorp/plugin-hcp-consul-backend
yarn add @hashicorp/plugin-hcp-consul-backend
bun add @hashicorp/plugin-hcp-consul-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.1.3 |
| Published | 2024-01-05 |
| First published | 2023-11-24 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 28.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Abhishek Sahu, Tauhid Anjum - Hashicorp |
| Maintainers | abhishek-hashicorp, dstaley, cameronperera, alexju, consul-ui-services, wenincode-hashicorp, hashicb, britt.lindgren, paulhcp, nandereck, tstormk, hashibot-hds, lackeyjb1, youriwims, jpogran, _natmegs, thrashr888, amyrlam, melsumner, mwickett, didoo, zchsh, hcitsec, gregone, meirish, enmod, kaxcode, anubhavmishra-hashicorp, hashibot-web, cstitt-hashi, kstraut, mocohen, dhaulagiri |
| Keywords | hcp, consul, backstage, plugin-hcp-consul-backend |

## Links

- npm: https://www.npmjs.com/package/@hashicorp/plugin-hcp-consul-backend
- Repository: https://github.com/hashicorp-forge/backstage-plugin-hcp-consul
- Homepage: https://github.com/hashicorp-forge/backstage-plugin-hcp-consul#readme
- Issues: https://github.com/hashicorp-forge/backstage-plugin-hcp-consul/issues
- npm.io page: https://npm.io/package/@hashicorp/plugin-hcp-consul-backend

## Dependencies (8)

- [yn](https://npm.io/package/yn.md) ^4.0.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [@types/express](https://npm.io/package/@types/express.md) *
- [@backstage/config](https://npm.io/package/@backstage/config.md) ^1.1.1
- [express-promise-router](https://npm.io/package/express-promise-router.md) ^4.1.0
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.15.0

## Recent versions

- 0.1.3 (latest) — 2024-01-05
- 0.1.2 — 2023-11-28
- 0.1.1 — 2023-11-24

## README

# @hashicorp/plugin-hcp-consul-backend

A backend for HCP Consul, this plugin exposes a services with routes that are used by the `@hashicorp/plugin-hcp-consul` plugin to query HCP Consul overview and service instances using HCP Consul Central public APIs.

## Set Up

1. Install the plugin using:

```bash
# From your Backstage root directory
yarn add --cwd packages/backend @hashicorp/plugin-hcp-consul-backend
```

2. Create a `hcp-consul-backend.ts` file inside `packages/backend/src/plugins/`:

```typescript
import { createRouter } from '@hashicorp/plugin-hcp-consul-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter(env);
}
```

3. Modify your `packages/backend/src/index.ts` to include:

```diff
 ...

 import { Config } from '@backstage/config';
 import app from './plugins/app';
+import consul from './plugins/hcp-consul-backend';
 ...

 async function main() {
   ...

   const authEnv = useHotMemoize(module, () => createEnv('auth'));
+  const consulBackendEnv = useHotMemoize(module, () => createEnv('consul'));
   ...

   const apiRouter = Router();
   apiRouter.use('/catalog', await catalog(catalogEnv));
+  apiRouter.use('/hcp-consul-backend', await consul(consulBackendEnv));
```

Note: for this backend to work, the `consul` configuration described in the README of `@hashicorp/plugin-hcp-consul` must be implemented.

---
_Source: https://npm.io/package/@hashicorp/plugin-hcp-consul-backend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
