Airbrake backend: Support the new backend system

Signed-off-by: Niklas Aronsson <niklasar@axis.com>
This commit is contained in:
Niklas Aronsson
2023-07-06 07:09:30 +02:00
parent 06c88a8d30
commit a95bb64e46
7 changed files with 72 additions and 0 deletions
+1
View File
@@ -22,3 +22,4 @@
export * from './service/router';
export * from './config';
export { airbrakePlugin } from './plugin';
+49
View File
@@ -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),
}),
);
},
});
},
});