Skip to content

Commit

Permalink
nomad - Removed usages and references of @backstage/backend-common (#…
Browse files Browse the repository at this point in the history
…1961)

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

Signed-off-by: Andre Wanlin <[email protected]>

* Fixed reference

Signed-off-by: Andre Wanlin <[email protected]>

* Added error middleware

Signed-off-by: Andre Wanlin <[email protected]>

* Added deprecation

Signed-off-by: Andre Wanlin <[email protected]>

* Updated changeset and reports

Signed-off-by: Andre Wanlin <[email protected]>

---------

Signed-off-by: Andre Wanlin <[email protected]>
  • Loading branch information
awanlin authored Nov 18, 2024
1 parent 0555e21 commit 75644d9
Show file tree
Hide file tree
Showing 6 changed files with 520 additions and 66 deletions.
7 changes: 7 additions & 0 deletions workspaces/nomad/.changeset/perfect-birds-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@backstage-community/plugin-nomad-backend': patch
---

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

Deprecated `createRouter` and its router options in favour of the new backend system.
4 changes: 2 additions & 2 deletions workspaces/nomad/plugins/nomad-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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",
"@backstage/errors": "^1.2.4",
Expand All @@ -47,7 +47,7 @@
"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",
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.1",
Expand Down
4 changes: 2 additions & 2 deletions workspaces/nomad/plugins/nomad-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ 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
const nomadPlugin: BackendFeature;
export default nomadPlugin;

// @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 @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getVoidLogger } from '@backstage/backend-common';
import { mockServices } from '@backstage/backend-test-utils';
import express from 'express';
import request from 'supertest';

Expand All @@ -31,7 +31,7 @@ describe('createRouter', () => {
token: 'asdf',
},
}),
logger: getVoidLogger(),
logger: mockServices.rootLogger(),
});
app = express().use(router);
});
Expand Down
15 changes: 10 additions & 5 deletions workspaces/nomad/plugins/nomad-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@
*/

import fetch from 'node-fetch';
import { errorHandler, requestLoggingHandler } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { InputError } from '@backstage/errors';
import express from 'express';
import Router from 'express-promise-router';
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 {
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 @@ -120,7 +126,6 @@ export async function createRouter(
resp.json(versionsBody);
});

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

0 comments on commit 75644d9

Please sign in to comment.