catalog-backend-module-unprocessed: refactor for forwards compatibility

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-02-15 14:37:04 +01:00
parent 0dc66a6912
commit d3dd64a90b
4 changed files with 7 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-unprocessed': patch
---
Explicitly only depend on the `use` method from the `HttpRouterService`.
+1 -1
View File
@@ -13,7 +13,7 @@ export default catalogModuleUnprocessedEntities;
// @public
export class UnprocessedEntitiesModule {
constructor(database: Knex, router: HttpRouterService);
constructor(database: Knex, router: Pick<HttpRouterService, 'use'>);
// (undocumented)
registerRoutes(): void;
}
@@ -23,7 +23,6 @@ import {
import { Knex } from 'knex';
import { HttpRouterService } from '@backstage/backend-plugin-api';
import Router from 'express-promise-router';
import { getBearerTokenFromAuthorizationHeader } from '@backstage/plugin-auth-node';
/**
* Module providing Unprocessed Entities API endpoints
@@ -35,7 +34,7 @@ export class UnprocessedEntitiesModule {
constructor(
private readonly database: Knex,
private readonly router: HttpRouterService,
private readonly router: Pick<HttpRouterService, 'use'>,
) {
this.moduleRouter = Router();
this.router.use(this.moduleRouter);
@@ -111,9 +110,6 @@ export class UnprocessedEntitiesModule {
await this.unprocessed({
reason: 'failed',
owner: req.query.owner as string,
authorizationToken: getBearerTokenFromAuthorizationHeader(
req.header('authorization'),
),
}),
);
})
@@ -122,9 +118,6 @@ export class UnprocessedEntitiesModule {
await this.unprocessed({
reason: 'pending',
owner: req.query.owner as string,
authorizationToken: getBearerTokenFromAuthorizationHeader(
req.header('authorization'),
),
}),
);
});
@@ -60,7 +60,6 @@ export type RefreshStateError = {
export interface UnprocessedEntitiesRequest {
reason: 'failed' | 'pending';
owner?: string;
authorizationToken?: string;
}
export interface UnprocessedEntitiesResponse {