diff --git a/workspaces/rollbar/.changeset/beige-papayas-approve.md b/workspaces/rollbar/.changeset/beige-papayas-approve.md new file mode 100644 index 0000000000..0fa3104d8f --- /dev/null +++ b/workspaces/rollbar/.changeset/beige-papayas-approve.md @@ -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. diff --git a/workspaces/rollbar/plugins/rollbar-backend/package.json b/workspaces/rollbar/plugins/rollbar-backend/package.json index a2487c8490..557873ef0b 100644 --- a/workspaces/rollbar/plugins/rollbar-backend/package.json +++ b/workspaces/rollbar/plugins/rollbar-backend/package.json @@ -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", diff --git a/workspaces/rollbar/plugins/rollbar-backend/report.api.md b/workspaces/rollbar/plugins/rollbar-backend/report.api.md index 4507d97a13..d5af252ee5 100644 --- a/workspaces/rollbar/plugins/rollbar-backend/report.api.md +++ b/workspaces/rollbar/plugins/rollbar-backend/report.api.md @@ -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; // @public (undocumented) @@ -219,7 +219,7 @@ export type RollbarTopActiveItem = { counts: number[]; }; -// @public (undocumented) +// @public @deprecated (undocumented) export interface RouterOptions { // (undocumented) config: Config; diff --git a/workspaces/rollbar/plugins/rollbar-backend/src/api/RollbarApi.test.ts b/workspaces/rollbar/plugins/rollbar-backend/src/api/RollbarApi.test.ts index 3c56c1c89d..c4f7697b9e 100644 --- a/workspaces/rollbar/plugins/rollbar-backend/src/api/RollbarApi.test.ts +++ b/workspaces/rollbar/plugins/rollbar-backend/src/api/RollbarApi.test.ts @@ -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' }, diff --git a/workspaces/rollbar/plugins/rollbar-backend/src/service/router.test.ts b/workspaces/rollbar/plugins/rollbar-backend/src/service/router.test.ts index 2e6c8a663a..a8b65d15b0 100644 --- a/workspaces/rollbar/plugins/rollbar-backend/src/service/router.test.ts +++ b/workspaces/rollbar/plugins/rollbar-backend/src/service/router.test.ts @@ -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; @@ -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); diff --git a/workspaces/rollbar/plugins/rollbar-backend/src/service/router.ts b/workspaces/rollbar/plugins/rollbar-backend/src/service/router.ts index 450463801a..7339d4ad77 100644 --- a/workspaces/rollbar/plugins/rollbar-backend/src/service/router.ts +++ b/workspaces/rollbar/plugins/rollbar-backend/src/service/router.ts @@ -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 { @@ -85,8 +91,7 @@ export async function createRouter( }); } - router.use(errorHandler()); - + router.use(MiddlewareFactory.create({ config, logger }).error()); return router; } diff --git a/workspaces/rollbar/yarn.lock b/workspaces/rollbar/yarn.lock index 63334c30c5..3e70071932 100644 --- a/workspaces/rollbar/yarn.lock +++ b/workspaces/rollbar/yarn.lock @@ -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