Airbrake backend: Support the new backend system
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-airbrake-backend': patch
|
||||
---
|
||||
|
||||
Added support for the [new backend system](https://backstage.io/docs/backend-system/)
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { Config } from '@backstage/config';
|
||||
import express from 'express';
|
||||
import { Logger } from 'winston';
|
||||
@@ -12,6 +13,9 @@ export interface AirbrakeConfig {
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const airbrakePlugin: () => BackendFeature;
|
||||
|
||||
// @public
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
"@types/express": "*",
|
||||
"express": "^4.17.1",
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
|
||||
export * from './service/router';
|
||||
export * from './config';
|
||||
export { airbrakePlugin } from './plugin';
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouter } from './service/router';
|
||||
import { extractAirbrakeConfig } from './config';
|
||||
|
||||
/**
|
||||
* The Airbrake Backend plugin.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const airbrakePlugin = createBackendPlugin({
|
||||
pluginId: 'airbrake',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.config,
|
||||
logger: coreServices.logger,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
},
|
||||
async init({ logger, httpRouter, config }) {
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
airbrakeConfig: extractAirbrakeConfig(config),
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -98,6 +98,17 @@ The Airbrake plugin provides connectivity between Backstage and Airbrake (https:
|
||||
}
|
||||
```
|
||||
|
||||
```typescript
|
||||
// Using the new backend system
|
||||
import { airbrakePlugin } from '@backstage/plugin-airbrake-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
backend.add(airbrakePlugin());
|
||||
// ... other feature additions
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
6. Add this config as a top level section in your `app-config.yaml`:
|
||||
|
||||
```yaml
|
||||
|
||||
@@ -4656,6 +4656,7 @@ __metadata:
|
||||
resolution: "@backstage/plugin-airbrake-backend@workspace:plugins/airbrake-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
"@types/express": "*"
|
||||
|
||||
Reference in New Issue
Block a user