rollbar - Removed usages and references of `@backstage/backend-common` (#1956)

* rollbar - Removed usages and references of `@backstage/backend-common`

Signed-off-by: Andre Wanlin <awanlin@spotify.com>

* Added error middleware

Signed-off-by: Andre Wanlin <awanlin@spotify.com>

* Added deprecation

Signed-off-by: Andre Wanlin <awanlin@spotify.com>

* Updated changeset and reports

Signed-off-by: Andre Wanlin <awanlin@spotify.com>

---------

Signed-off-by: Andre Wanlin <awanlin@spotify.com>
This commit is contained in:
Andre Wanlin 2024-11-18 13:40:08 -07:00 committed by GitHub
parent fdcc96dc79
commit 3a74e4b6ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 27 additions and 15 deletions

View File

@ -0,0 +1,7 @@
---
'@backstage-community/plugin-rollbar-backend': patch
---
Removed usages and references of `@backstage/backend-common`
Deprecated `createRouter` and its router options in favour of the new backend system.

View File

@ -42,7 +42,7 @@
"test": "backstage-cli package test"
},
"dependencies": {
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-defaults": "^0.5.2",
"@backstage/backend-plugin-api": "^1.0.1",
"@backstage/config": "^1.2.0",
"@types/express": "^4.17.6",
@ -58,7 +58,6 @@
"yn": "^4.0.0"
},
"devDependencies": {
"@backstage/backend-defaults": "^0.5.2",
"@backstage/backend-test-utils": "^1.0.2",
"@backstage/cli": "^0.28.0",
"@backstage/plugin-auth-backend": "^0.23.1",

View File

@ -8,7 +8,7 @@ import { Config } from '@backstage/config';
import express from 'express';
import { LoggerService } from '@backstage/backend-plugin-api';
// @public (undocumented)
// @public @deprecated (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
@ -219,7 +219,7 @@ export type RollbarTopActiveItem = {
counts: number[];
};
// @public (undocumented)
// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
config: Config;

View File

@ -15,10 +15,12 @@
*/
import { getRequestHeaders, RollbarApi } from './RollbarApi';
import { registerMswTestHooks } from '@backstage/backend-test-utils';
import {
mockServices,
registerMswTestHooks,
} from '@backstage/backend-test-utils';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { getVoidLogger } from '@backstage/backend-common';
describe('RollbarApi', () => {
describe('getRequestHeaders', () => {
@ -58,7 +60,7 @@ describe('RollbarApi', () => {
it('should return all projects with a name attribute', async () => {
setupHandlers();
const api = new RollbarApi('my-access-token', getVoidLogger());
const api = new RollbarApi('my-access-token', mockServices.rootLogger());
const projects = await api.getAllProjects();
expect(projects).toEqual([
{ id: 123, name: 'abc', accountId: 1, status: 'enabled' },

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
import { getVoidLogger } from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';
import express from 'express';
import request from 'supertest';
import { RollbarApi } from '../api';
import { createRouter } from './router';
import { RollbarProject, RollbarTopActiveItem } from '../api/types';
import { mockServices } from '@backstage/backend-test-utils';
describe('createRouter', () => {
let rollbarApi: jest.Mocked<RollbarApi>;
@ -37,7 +37,7 @@ describe('createRouter', () => {
} as any;
const router = await createRouter({
rollbarApi,
logger: getVoidLogger(),
logger: mockServices.rootLogger(),
config: new ConfigReader({ rollbar: { accountToken: 'foo' } }),
});
app = express().use(router);

View File

@ -16,19 +16,25 @@
import express from 'express';
import Router from 'express-promise-router';
import { errorHandler } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { RollbarApi } from '../api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
/** @public */
/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public */
export interface RouterOptions {
rollbarApi?: RollbarApi;
logger: LoggerService;
config: Config;
}
/** @public */
/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
@ -85,8 +91,7 @@ export async function createRouter(
});
}
router.use(errorHandler());
router.use(MiddlewareFactory.create({ config, logger }).error());
return router;
}

View File

@ -2516,7 +2516,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@backstage-community/plugin-rollbar-backend@workspace:plugins/rollbar-backend"
dependencies:
"@backstage/backend-common": ^0.25.0
"@backstage/backend-defaults": ^0.5.2
"@backstage/backend-plugin-api": ^1.0.1
"@backstage/backend-test-utils": ^1.0.2