Skip to content

Commit

Permalink
fix: remove deprecated functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
drodil committed Aug 20, 2024
1 parent 6be1589 commit 0670663
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion plugins/qeta-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.540.0",
"@backstage/backend-common": "^0.24.0",
"@backstage/backend-defaults": "^0.4.2",
"@backstage/backend-plugin-api": "^0.8.0",
"@backstage/catalog-model": "^1.6.0",
"@backstage/config": "^1.2.0",
Expand Down Expand Up @@ -76,7 +77,6 @@
"yn": "^4.0.0"
},
"devDependencies": {
"@backstage/backend-defaults": "^0.4.2",
"@backstage/backend-test-utils": "^0.5.0",
"@backstage/cli": "^0.27.0",
"@backstage/plugin-auth-backend": "^0.22.10",
Expand Down
7 changes: 4 additions & 3 deletions plugins/qeta-backend/src/database/DatabaseQetaStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
PluginDatabaseManager,
DatabaseService,
resolvePackagePath,
} from '@backstage/backend-common';
} from '@backstage/backend-plugin-api';

import { Knex } from 'knex';
import {
Answers,
Expand Down Expand Up @@ -95,7 +96,7 @@ export class DatabaseQetaStore implements QetaStore {
database,
skipMigrations,
}: {
database: PluginDatabaseManager;
database: DatabaseService;
skipMigrations?: boolean;
}): Promise<DatabaseQetaStore> {
const client = await database.getClient();
Expand Down
2 changes: 0 additions & 2 deletions plugins/qeta-backend/src/service/CatalogMockRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import express from 'express';
import Router from 'express-promise-router';
import { errorHandler } from '@backstage/backend-common';
// @eslint-ignore
import { stringifyEntityRef } from '@backstage/catalog-model';

Expand Down Expand Up @@ -102,6 +101,5 @@ export const createCatalogMockRouter = async (): Promise<express.Router> => {
});
});

router.use(errorHandler());
return router;
};
3 changes: 1 addition & 2 deletions plugins/qeta-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { getVoidLogger } from '@backstage/backend-common';
import express from 'express';
import request from 'supertest';

Expand Down Expand Up @@ -166,7 +165,7 @@ describe('createRouter', () => {
{ context: 'qeta', data: qetaConfig || {} },
]);
const router = await createRouter({
logger: getVoidLogger(),
logger: mockServices.logger.mock(),
httpAuth: mockServices.httpAuth(),
userInfo: mockServices.userInfo(),
discovery: mockServices.discovery(),
Expand Down
6 changes: 3 additions & 3 deletions plugins/qeta-backend/src/service/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import express from 'express';
import Router from 'express-promise-router';
import bodyParser from 'body-parser';
import { errorHandler } from '@backstage/backend-common';
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
import { qetaPermissions } from '@drodil/backstage-plugin-qeta-common';
import { statisticRoutes } from './routes/statistics';
Expand All @@ -11,14 +10,15 @@ import { answersRoutes } from './routes/answers';
import { helperRoutes } from './routes/helpers';
import { RouterOptions } from './types';
import { NotificationManager } from './NotificationManager';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';

export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const router = Router();
router.use(express.json());
router.use(bodyParser.urlencoded({ extended: true }));
const { logger, httpAuth } = options;
const { config, logger, httpAuth } = options;
const notificationMgr = new NotificationManager(
logger,
options.notifications,
Expand Down Expand Up @@ -46,6 +46,6 @@ export async function createRouter(
attachmentsRoutes(router, routeOptions);
statisticRoutes(router, routeOptions);

router.use(errorHandler());
router.use(MiddlewareFactory.create({ config, logger }).error);
return router;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const QuestionHighlightList = (props: {
type: string;
title: string;
noQuestionsLabel: string;
icon?: JSX.Element;
icon?: React.ReactNode;
}) => {
const {
value: response,
Expand Down
13 changes: 7 additions & 6 deletions plugins/search-backend-module-qeta/src/collators/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Config } from '@backstage/config';
import {
readTaskScheduleDefinitionFromConfig,
TaskScheduleDefinition,
} from '@backstage/backend-tasks';
readSchedulerServiceTaskScheduleDefinitionFromConfig,
SchedulerServiceTaskScheduleDefinition,
} from '@backstage/backend-plugin-api';
import { InputError } from '@backstage/errors';

const configKey = 'search.collators.qeta';
Expand All @@ -17,15 +17,16 @@ export const defaults = {

export function readScheduleConfigOptions(
configRoot: Config,
): TaskScheduleDefinition {
let schedule: TaskScheduleDefinition | undefined = undefined;
): SchedulerServiceTaskScheduleDefinition {
let schedule: SchedulerServiceTaskScheduleDefinition | undefined = undefined;

const config = configRoot.getOptionalConfig(configKey);
if (config) {
const scheduleConfig = config.getOptionalConfig('schedule');
if (scheduleConfig) {
try {
schedule = readTaskScheduleDefinitionFromConfig(scheduleConfig);
schedule =
readSchedulerServiceTaskScheduleDefinitionFromConfig(scheduleConfig);
} catch (error) {
throw new InputError(`Invalid schedule at ${configKey}, ${error}`);
}
Expand Down

0 comments on commit 0670663

Please sign in to comment.