Scaffolder: HTTP Requests logo

Backstage HTTP request scaffolder actions

Created by Roadie

The Backstage HTTP request scaffolder actions plugin integrates with the pre-existing scaffolder actions. It extends them and allows you to send arbitrary http requests to your Backstage instance.

The http:backstage:request action allows the task to call any of the backstage APIs available to the user that triggers it. The action takes care of passing the authentication token of the user to the task execution so that the action can perform actions on behalf of the user that triggers it.

Installation Instructions

These instructions apply to self-hosted Backstage only.

Install the plugin into your scaffolded Backstage application.

Copy
cd packages/backend
yarn add @roadiehq/scaffolder-backend-module-http-request

Add http request actions to your scaffolder backend

Copy
// packages/backend/src/plugins/scaffolder.ts

const actions = [
  createHttpBackstageAction({ config }),
  ...createBuiltinActions({
    containerRunner,
    integrations,
    config,
    catalogClient,
    reader,
  }),
];

return await createRouter({
  containerRunner,
  logger,
  config,
  database,
  catalogClient,
  reader,
  actions,
});

Create template with http actions

Copy
...
  steps:
    - id: backstage_request
      name: backstage request
      action: http:backstage:request
      input:
        method: 'GET'
        path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues'
        headers:
          test: 'hello'
          foo: 'bar'
        params:
          name: 'test'
          bar: 'foo'

    - id: backstage_request_with_input
      name: backstage request
      action: http:backstage:request
      input:
        method: 'POST'
        path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues/get/some/job{{ steps["backstage_request"].output.body.number }}'
        headers:
            test: 'hello'
            foo: 'bar'
        body:
            name: 'test'
            bar: 'foo'

  output:
    getResponse: '{{ steps["backstage_request_with_input"].output.body }}'
    getCode: '{{ steps["backstage_request_with_input"].output.code }}'
    getHeaders: '{{ steps["backstage_request_with_input"].output.headers }}'
...

Things to Know

This scaffolder action is meant to be used in a scaffolded Backstage application created by Backstage CLI. If you are using it in a Backstage monorepo, you need to modify the build process to transpile node_modules also.

NB: The path should always point to a proxy entry with the following format: proxy/<proxy-path>/<external-api-path>. i.e.: /proxy/snyk/org/<some-org>/projects or /proxy/circleci/api/projects (the CircleCI proxy path is circleci/api/ but Snyk is just snyk/)

Changelog

This changelog is produced from commits made to the Scaffolder: HTTP Requests plugin since a year ago, and based on the code located here. It may not contain information about all commits. Releases and version bumps are intentionally omitted. This changelog is generated by AI.

Features

  • Accept both LoggerService and winston Logger in the backend module #1747 merged 9 months ago

Bug fixes

  • Make the Content Type header case insensitive so JSON bodies serialize as expected #2048 merged 3 weeks ago

Improvements

  • Use native AbortSignal timeout for request timeouts which reduces custom timer code #1946 merged 3 months ago

Deprecations

  • Deprecate the export in the new backend module use the re export from index ts instead #1712 merged 10 months ago

Maintenance

  • Update backstage pluginId metadata to match createBackendModule pluginId #2042 merged 3 weeks ago
  • Remove direct dependency on the scaffolder backend in this module #1730 merged 10 months ago

Set up Backstage in minutes with Roadie