# @qtorque/backstage-plugin-torque-backend

> `@qtorque/backstage-plugin-torque-backend` is a plugin for the Backstage backend app. It provides a route that `@qtorque/backstage-plugin-torque` is using to communicate with Torque API and scaffolder action to create a service and all needed infrastructi

Latest version **0.1.5** (published 2023-03-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @qtorque/backstage-plugin-torque-backend
pnpm add @qtorque/backstage-plugin-torque-backend
yarn add @qtorque/backstage-plugin-torque-backend
bun add @qtorque/backstage-plugin-torque-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.5 |
| Published | 2023-03-20 |
| First published | 2023-01-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 26.5 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | davidbquali, dmytro.d-quali, qualiit |

## Links

- npm: https://www.npmjs.com/package/@qtorque/backstage-plugin-torque-backend
- npm.io page: https://npm.io/package/@qtorque/backstage-plugin-torque-backend

## Dependencies (11)

- [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.0.7
- [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.18.3
- [@backstage/backend-plugin-api](https://npm.io/package/@backstage/backend-plugin-api.md) ^0.5.0
- [@backstage/plugin-scaffolder-backend](https://npm.io/package/@backstage/plugin-scaffolder-backend.md) ^1.11.0
- [@qtorque/backstage-plugin-torque-common](https://npm.io/package/@qtorque/backstage-plugin-torque-common.md) ^0.1.2

## Recent versions

- 0.1.5 (latest) — 2023-03-20
- 0.1.4 — 2023-03-20
- 0.1.3 — 2023-03-17
- 0.1.2 — 2023-01-25
- 0.1.1 — 2023-01-24
- 0.1.0 — 2023-01-23

## README

# @qtorque/backstage-plugin-torque-backend

`@qtorque/backstage-plugin-torque-backend` is a plugin for the Backstage backend app. It provides a route that `@qtorque/backstage-plugin-torque` is using to communicate with Torque API and scaffolder action to create a service and all needed infrastruction with Torque.

## Installation

1. Install `@qtorque/backstage-plugin-torque-backend` plugin with,

```bash
yarn workspace backend add @qtorque/backstage-plugin-torque-backend
```

2. Create `./packages/backend/src/plugins/torque.ts` with the following content,

```ts
import { createRouter } from '@qtorque/backstage-plugin-torque-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

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

3. Add `torque` api route to `./packages/backend/src/index.ts`.

```diff
import search from './plugins/search';
+ import torque from './plugins/torque';

const searchEnv = useHotMemoize(module, () => createEnv('search'));
+ const torqueEnv = useHotMemoize(module, () => createEnv('torque'));

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
+ apiRouter.use('/torque', await torque(torqueEnv));
```

4. Add configuration to `app-config.yaml`

```yaml
torque:
  token: ${TORQUE_TOKEN} # without Bearer
  executionHost: ${TORQUE_AGENT_NAME} # the name of agent registered in Torque
  serverUrl: ${TORQUE_URL} # default is https://portal.qtorque.io
  ghAccessToken: ${GITHUB_TOKEN} # github token
```

## Scaffolder Actions

This plugin provides the following scaffolder actions:

### create-app

`create-app` will prepare an infrastructure in Torque and create an environment for service. 

#### Installation

To make this action available, you can add it to your scaffolder plugin configuration in `./packages/backend/src/plugins/scaffolder.ts`

```diff
# import createTorqueApp action
+ import { createTorqueApp } from "@qtorque/backstage-plugin-torque-backend";

# register the action
  const actions = [
    ...builtInActions,
    createTorqueApp({
+      token: config.getString('torque.token'),
+      executionHost: config.getString('torque.executionHost'),
+      ghAccessToken: config.getString('torque.ghAccessToken'),
+      serverUrl: config.getOptionalString('torque.serverUrl')
    })
  ];
```

### Usage

Add the action to your template,

```yaml
    - name: Deploy with Torque
      id: torque-app-id
      action: torque:create-app
      input:
        serviceName: ${{ parameters.componentName }} # The name of service that will be created in Torque. 
        # Will be used as space, assets repo, blueprint repo and grain names
        assetRepo: ${{ steps.publish.output.remoteUrl }} # The asset repo that will be connected to Torque
        blueprintRepo: ${{ steps.publish.output.remoteUrl }} # The blueprints repo that will be connected to Torque
        serviceAccount: 'default' # A k8s service account to assign to agent
        namespace: default # A k8s namespace to assign to agent
        blueprintName: ${{ parameters.componentName }} # The name of a blueprint you that will be a source for sandbox environment
```

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