Skip to content

Commit

Permalink
rollbar - Removed usages and references of @backstage/backend-common (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
awanlin authored Nov 18, 2024
1 parent fdcc96d commit 3a74e4b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
7 changes: 7 additions & 0 deletions workspaces/rollbar/.changeset/beige-papayas-approve.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 1 addition & 2 deletions workspaces/rollbar/plugins/rollbar-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions workspaces/rollbar/plugins/rollbar-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -219,7 +219,7 @@ export type RollbarTopActiveItem = {
counts: number[];
};

// @public (undocumented)
// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
config: Config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions workspaces/rollbar/plugins/rollbar-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -85,8 +91,7 @@ export async function createRouter(
});
}

router.use(errorHandler());

router.use(MiddlewareFactory.create({ config, logger }).error());
return router;
}

Expand Down
1 change: 0 additions & 1 deletion workspaces/rollbar/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a74e4b

Please sign in to comment.