0.4.1 • Published 18 days ago

@backstage/plugin-badges-backend v0.4.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
18 days ago

Badges Backend

Backend plugin for serving badges to the @backstage/plugin-badges plugin. Default implementation uses badge-maker for creating the badges, in SVG.

Currently, only entity badges are implemented. i.e. badges that may have entity specific information in them, and as such, are served from an entity specific endpoint.

Installation

Install the @backstage/plugin-badges-backend package in your backend package, and then integrate the plugin using the following default setup for src/plugins/badges.ts:

import {
  createRouter,
  createDefaultBadgeFactories,
} from '@backstage/plugin-badges-backend';
import { PluginEnvironment } from '../types';

export default async function createPlugin({
  config,
  discovery,
}: PluginEnvironment) {
  return await createRouter({
    config,
    discovery,
    badgeFactories: createDefaultBadgeFactories(),
  });
}

The createDefaultBadgeFactories() returns an object with badge factories to the badges-backend createRouter() to forward to the default badge builder. To customize the available badges, provide a custom set of badge factories. See further down for an example of a custom badge factories function.

Badge builder

Badges are created by classes implementing the BadgeBuilder type. The default badge builder uses badge factories to turn a BadgeContext into a Badge spec for the badge-maker to create the SVG image.

Default badges

A set of default badge factories are defined in badges.ts as examples.

Additional badges may be provided in your application by defining custom badge factories, and provide them to the badge builder.

Custom badges

To provide custom badges, create a badge factories function, and use that when creating the badges backend router.

import type { Badge, BadgeContext, BadgeFactories } from '@backstage/plugin-badges-backend';
export const createMyCustomBadgeFactories = (): BadgeFactories => ({
    <custom-badge-id>: {
        createBadge: (context: BadgeContext): Badge | null => {
            // ...
            return {
                label: 'my-badge',
                message: 'custom stuff',
                // ...
            };
        },
    },

    // optional: include the default badges
    // ...createDefaultBadgeFactories(),
});

API

The badges backend api exposes two main endpoints for entity badges. The /badges prefix is arbitrary, and the default for the example backend.

  • /badges/entity/:namespace/:kind/:name/badge-specs List all defined badges for a particular entity, in json format. See BadgeSpec from the frontend plugin for a type declaration.

  • /badges/entity/:namespace/:kind/:name/badge/:badgeId Get the entity badge as an SVG image. If the accept request header prefers application/json the badge spec as JSON will be returned instead of the image.

Links

0.4.1

20 days ago

0.4.0

23 days ago

0.3.14-next.1

1 month ago

0.3.14-next.0

1 month ago

0.3.13

1 month ago

0.3.12

2 months ago

0.3.11

2 months ago

0.3.11-next.2

2 months ago

0.3.11-next.1

2 months ago

0.3.10

2 months ago

0.3.10-next.0

2 months ago

0.3.8

3 months ago

0.3.9

3 months ago

0.3.7

3 months ago

0.3.7-next.3

3 months ago

0.3.7-next.2

3 months ago

0.3.7-next.1

3 months ago

0.3.7-next.0

4 months ago

0.3.6

4 months ago

0.3.6-next.2

4 months ago

0.3.6-next.1

4 months ago

0.3.6-next.0

5 months ago

0.3.5

5 months ago

0.3.5-next.3

5 months ago

0.3.5-next.2

5 months ago

0.3.5-next.1

5 months ago

0.2.5-next.0

9 months ago

0.3.3-next.2

7 months ago

0.3.4-next.2

6 months ago

0.3.4-next.1

6 months ago

0.3.4-next.0

7 months ago

0.3.0-next.3

8 months ago

0.2.3-next.2

9 months ago

0.2.3-next.1

9 months ago

0.2.3-next.0

10 months ago

0.3.0

8 months ago

0.3.2

7 months ago

0.3.1

8 months ago

0.3.4

6 months ago

0.3.3

7 months ago

0.3.2-next.1

7 months ago

0.3.2-next.0

8 months ago

0.3.5-next.0

6 months ago

0.2.6-next.1

8 months ago

0.2.6-next.2

8 months ago

0.2.2-next.1

10 months ago

0.2.3

9 months ago

0.2.2

10 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.2.1-next.3

11 months ago

0.2.1-next.2

11 months ago

0.2.2-next.0

11 months ago

0.2.1

11 months ago

0.2.0-next.2

1 year ago

0.1.39-next.1

1 year ago

0.2.1-next.1

12 months ago

0.2.1-next.0

12 months ago

0.2.0

12 months ago

0.1.39-next.0

1 year ago

0.1.38-next.3

1 year ago

0.1.38

1 year ago

0.1.38-next.1

1 year ago

0.1.38-next.0

1 year ago

0.1.38-next.2

1 year ago

0.1.37-next.0

1 year ago

0.1.37-next.1

1 year ago

0.1.37-next.2

1 year ago

0.1.36

1 year ago

0.1.37

1 year ago

0.1.34-next.1

1 year ago

0.1.34-next.2

1 year ago

0.1.36-next.2

1 year ago

0.1.36-next.1

1 year ago

0.1.36-next.0

1 year ago

0.1.34

1 year ago

0.1.35

1 year ago

0.1.34-next.0

1 year ago

0.1.32-next.0

2 years ago

0.1.32-next.1

2 years ago

0.1.33-next.0

1 year ago

0.1.33-next.3

1 year ago

0.1.33-next.2

1 year ago

0.1.33-next.1

1 year ago

0.1.31

2 years ago

0.1.32

1 year ago

0.1.33

1 year ago

0.1.31-next.0

2 years ago

0.1.31-next.2

2 years ago

0.1.31-next.1

2 years ago

0.1.30

2 years ago

0.1.30-next.0

2 years ago

0.1.30-next.1

2 years ago

0.1.29-next.0

2 years ago

0.1.28-next.0

2 years ago

0.1.28-next.2

2 years ago

0.1.28-next.1

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.27-next.2

2 years ago

0.1.27-next.1

2 years ago

0.1.27-next.0

2 years ago

0.1.26

2 years ago

0.1.26-next.0

2 years ago

0.1.26-next.1

2 years ago

0.1.25-next.1

2 years ago

0.1.25-next.0

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.23-next.0

2 years ago

0.1.22

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.18-next.0

2 years ago

0.1.16-next.0

2 years ago

0.1.17-next.0

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago