Skip to content

Commit

Permalink
fix(deps): replace deprecated functionality (#1977)
Browse files Browse the repository at this point in the history
* fix(deps): replace deprecated functionality

Signed-off-by: Paul Schultz <pschultz@pobox.com>

* run prettier

Signed-off-by: Paul Schultz <pschultz@pobox.com>

* removed duplicate key

Signed-off-by: Paul Schultz <pschultz@pobox.com>

* update yarn lockfile

Signed-off-by: Paul Schultz <pschultz@pobox.com>

* fix tsc issues

Signed-off-by: Paul Schultz <pschultz@pobox.com>

---------

Signed-off-by: Paul Schultz <pschultz@pobox.com>
  • Loading branch information
schultzp2020 authored Sep 17, 2024
1 parent 54e321b commit 36ee0e4
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 186 deletions.
9 changes: 7 additions & 2 deletions plugins/audit-log-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
HttpAuthService,
LoggerService,
} from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';

/* highlight-add-start */
import { DefaultAuditLogger } from '@janus-idp/backstage-plugin-audit-log-node';
Expand All @@ -69,14 +70,15 @@ import { DefaultAuditLogger } from '@janus-idp/backstage-plugin-audit-log-node';

export interface RouterOptions {
logger: LoggerService;
config: Config;
auth: AuthService;
httpAuth: HttpAuthService;
}

export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger, auth, httpAuth } = options;
const { logger, config, auth, httpAuth } = options;

/* highlight-add-start */
const auditLogger = new DefaultAuditLogger({
Expand Down Expand Up @@ -111,7 +113,10 @@ export async function createRouter(
});
/* highlight-add-end */
});
router.use(errorHandler());

const middleware = MiddlewareFactory.create({ logger, config });

router.use(middleware.error());
return router;
}
```
Expand Down
4 changes: 3 additions & 1 deletion plugins/kiali-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,23 @@
"configSchema": "config.d.ts",
"dependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-defaults": "^0.4.1",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/catalog-client": "^1.6.5",
"@backstage/catalog-model": "^1.5.0",
"@backstage/config": "^1.2.0",
"@backstage/errors": "^1.2.4",
"@backstage/plugin-auth-node": "^0.4.17",
"@backstage/plugin-catalog-node": "^1.12.4",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"axios": "^1.7.4",
"express": "^4.18.2",
"express-promise-router": "^4.1.1",
"moment": "^2.29.4",
"yn": "^4.0.0"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.4.4",
"@backstage/cli": "0.26.11",
"@janus-idp/cli": "1.13.1",
"@types/express": "4.17.21",
Expand Down
4 changes: 2 additions & 2 deletions plugins/kiali-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getVoidLogger } from '@backstage/backend-common';
import { mockServices } from '@backstage/backend-test-utils';
import { ConfigReader } from '@backstage/config';

import express from 'express';
Expand All @@ -22,7 +22,7 @@ beforeAll(() =>
afterEach(() => server.restoreHandlers());
afterAll(() => server.close());

const logger = getVoidLogger();
const logger = mockServices.logger.mock();

describe('createRouter', () => {
let app: express.Express;
Expand Down
42 changes: 18 additions & 24 deletions plugins/kiali-backend/src/service/router.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { errorHandler } from '@backstage/backend-common';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
import { LoggerService } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';

import express from 'express';

import { KialiApiImpl } from '../clients/KialiAPIConnector';
import { KialiDetails, readKialiConfigs } from './config';
import { readKialiConfigs } from './config';

export interface RouterOptions {
logger: LoggerService;
config: Config;
}

export const makeRouter = (
logger: LoggerService,
kialiAPI: KialiApiImpl,
kiali: KialiDetails,
): express.Router => {
/** @public */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger } = options;
const { config } = options;

logger.info('Initializing Kiali backend');

const kiali = readKialiConfigs(config);

const kialiAPI = new KialiApiImpl({ logger, kiali });

const router = express.Router();
router.use(express.json());

Expand All @@ -39,22 +47,8 @@ export const makeRouter = (
res.json(await kialiAPI.status());
});

router.use(errorHandler());
return router;
};

/** @public */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger } = options;
const { config } = options;

logger.info('Initializing Kiali backend');

const kiali = readKialiConfigs(config);
const middleware = MiddlewareFactory.create({ logger, config });

const kialiAPI = new KialiApiImpl({ logger, kiali });

return makeRouter(logger, kialiAPI, kiali);
router.use(middleware.error());
return router;
}
3 changes: 2 additions & 1 deletion plugins/matomo-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
},
"dependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-defaults": "^0.4.1",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/config": "^1.2.0",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"@types/express": "4.17.20",
"express": "^4.18.2",
"express-promise-router": "^4.1.1",
Expand Down
1 change: 1 addition & 0 deletions plugins/matomo-backend/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const matomoBackendPlugin = createBackendPlugin({
logger.info('Matomo plugin is running');
const router = await createRouter({
config,
logger,
});
http.use(router);
},
Expand Down
19 changes: 0 additions & 19 deletions plugins/matomo-backend/src/run.ts

This file was deleted.

10 changes: 7 additions & 3 deletions plugins/matomo-backend/src/service/router.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { errorHandler } from '@backstage/backend-common';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
import { LoggerService } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';

import express from 'express';
import Router from 'express-promise-router';
import { createProxyMiddleware } from 'http-proxy-middleware';

export interface RouterOptions {
logger: LoggerService;
config: Config;
}

export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { config } = options;
const { logger, config } = options;

const matomoToken = config.getString('matomo.apiToken');
const matomoApiUrl = config.getString('matomo.apiUrl');
Expand Down Expand Up @@ -56,6 +58,8 @@ export async function createRouter(
}),
);

router.use(errorHandler());
const middleware = MiddlewareFactory.create({ logger, config });

router.use(middleware.error());
return router;
}
41 changes: 0 additions & 41 deletions plugins/matomo-backend/src/service/standaloneServer.ts

This file was deleted.

1 change: 1 addition & 0 deletions plugins/ocm-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"configSchema": "config.d.ts",
"dependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-defaults": "^0.4.1",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"@backstage/backend-openapi-utils": "^0.1.15",
"@backstage/backend-plugin-api": "^0.7.0",
Expand Down
14 changes: 7 additions & 7 deletions plugins/ocm-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
* limitations under the License.
*/

import {
createLegacyAuthAdapters,
errorHandler,
PluginEndpointDiscovery,
} from '@backstage/backend-common';
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
import {
coreServices,
createBackendPlugin,
DiscoveryService,
HttpAuthService,
LoggerService,
PermissionsService,
Expand Down Expand Up @@ -68,7 +66,7 @@ import { ManagedClusterInfo } from '../types';
export interface RouterOptions {
logger: LoggerService;
config: Config;
discovery: PluginEndpointDiscovery;
discovery: DiscoveryService;
permissions: PermissionsService;
httpAuth?: HttpAuthService;
}
Expand Down Expand Up @@ -185,7 +183,9 @@ const buildRouter = async (
return response.send(allClusters.flat());
});

router.use(errorHandler({ logClientErrors: true }));
const middleware = MiddlewareFactory.create({ logger, config });

router.use(middleware.error());
return router;
};

Expand Down
5 changes: 3 additions & 2 deletions plugins/orchestrator-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"dependencies": {
"@backstage/backend-app-api": "^0.8.0",
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-defaults": "^0.4.1",
"@backstage/backend-dynamic-feature-service": "^0.2.15",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/backend-tasks": "^0.5.27",
Expand Down Expand Up @@ -108,8 +109,8 @@
"@types/json-schema": "7.0.15"
},
"peerDependencies": {
"@janus-idp/backstage-plugin-rbac-common": "1.9.0",
"@janus-idp/backstage-plugin-audit-log-node": "1.4.0"
"@janus-idp/backstage-plugin-audit-log-node": "1.4.0",
"@janus-idp/backstage-plugin-rbac-common": "1.9.0"
},
"maintainers": [
"@janus-idp/maintainers-plugins",
Expand Down
15 changes: 9 additions & 6 deletions plugins/orchestrator-backend/src/routerWrapper/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { createLegacyAuthAdapters, UrlReader } from '@backstage/backend-common';
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import {
AuthService,
DiscoveryService,
HttpAuthService,
LoggerService,
PermissionsService,
SchedulerService,
UrlReaderService,
} from '@backstage/backend-plugin-api';
import { PluginTaskScheduler } from '@backstage/backend-tasks';
import { CatalogApi } from '@backstage/catalog-client';
import { Config } from '@backstage/config';

Expand All @@ -15,19 +16,21 @@ import express from 'express';
import { DevModeService } from '../service/DevModeService';
import { createBackendRouter } from '../service/router';

export interface RouterArgs {
export interface RouterOptions {
config: Config;
logger: LoggerService;
discovery: DiscoveryService;
catalogApi: CatalogApi;
urlReader: UrlReader;
scheduler: PluginTaskScheduler;
urlReader: UrlReaderService;
scheduler: SchedulerService;
permissions: PermissionsService;
httpAuth?: HttpAuthService;
auth?: AuthService;
}

export async function createRouter(args: RouterArgs): Promise<express.Router> {
export async function createRouter(
args: RouterOptions,
): Promise<express.Router> {
const autoStartDevMode =
args.config.getOptionalBoolean(
'orchestrator.sonataFlowService.autoStart',
Expand Down
Loading

0 comments on commit 36ee0e4

Please sign in to comment.