Skip to content

Commit

Permalink
chore(readme-backend): remove deprecations, unused deps and fix dev s…
Browse files Browse the repository at this point in the history
…erver (#183)

Co-authored-by: Niklas Aronsson <niklasar@axis.com>
Co-authored-by: Frida Jacobsson <frida.jacobsson@axis.com>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent 56e84d6 commit 176243f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 108 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-melons-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axis-backstage/plugin-readme-backend': patch
---

Updated deprecated types and fixed the standalone server
4 changes: 2 additions & 2 deletions plugins/readme-backend/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
```ts
import { AuthService } from '@backstage/backend-plugin-api';
import { BackendFeatureCompat } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import express from 'express';
import { LoggerService } from '@backstage/backend-plugin-api';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { TokenManagerService } from '@backstage/backend-plugin-api';
import { UrlReaderService } from '@backstage/backend-plugin-api';

Expand All @@ -22,7 +22,7 @@ export default readmePlugin;
// @public
export interface RouterOptions {
auth?: AuthService;
config: Config;
config: RootConfigService;
discovery: DiscoveryService;
logger: LoggerService;
reader: UrlReaderService;
Expand Down
5 changes: 5 additions & 0 deletions plugins/readme-backend/dev/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createBackend } from '@backstage/backend-defaults';

const backend = createBackend();
backend.add(import('../src'));
backend.start();
7 changes: 2 additions & 5 deletions plugins/readme-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@
"@backstage/backend-plugin-api": "^0.8.0",
"@backstage/catalog-client": "^1.6.6",
"@backstage/catalog-model": "^1.6.0",
"@backstage/config": "^1.2.0",
"@backstage/integration": "^1.14.0",
"@backstage/plugin-permission-common": "^0.8.1",
"@types/express": "*",
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
"node-fetch": "^2.6.7",
"yn": "^4.0.0"
"express-promise-router": "^4.1.0"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.5.0",
"@backstage/cli": "^0.27.0",
"@types/supertest": "^2.0.12",
"msw": "^1.0.0",
Expand Down
17 changes: 0 additions & 17 deletions plugins/readme-backend/src/run.ts

This file was deleted.

26 changes: 6 additions & 20 deletions plugins/readme-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
getVoidLogger,
HostDiscovery,
ServerTokenManager,
} from '@backstage/backend-common';
import { mockServices } from '@backstage/backend-test-utils';
import { UrlReaders } from '@backstage/backend-defaults/urlReader';
import { ConfigReader } from '@backstage/config';
import express from 'express';
import request from 'supertest';

Expand All @@ -14,23 +9,14 @@ describe('createRouter', () => {
let app: express.Express;

beforeAll(async () => {
const config = new ConfigReader({
backend: {
baseUrl: 'http://127.0.0.1:7007',
auth: {
keys: [{ secret: 'abcd' }],
},
},
});
const logger = getVoidLogger();
const discovery = HostDiscovery.fromConfig(config);
const tokenManager = ServerTokenManager.fromConfig(config, {
logger,
});
const config = mockServices.rootConfig();
const logger = mockServices.rootLogger.mock();
const discovery = mockServices.discovery.mock();
const tokenManager = mockServices.tokenManager.mock();
const reader = UrlReaders.default({ logger, config });

const router = await createRouter({
logger: getVoidLogger(),
logger,
config,
discovery,
tokenManager,
Expand Down
19 changes: 9 additions & 10 deletions plugins/readme-backend/src/service/router.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { errorHandler } from '@backstage/backend-common';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
import { CacheManager } from '@backstage/backend-defaults/cache';
import {
AuthService,
DiscoveryService,
LoggerService,
RootConfigService,
UrlReaderService,
TokenManagerService,
} from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import {
CacheManager,
createLegacyAuthAdapters,
} from '@backstage/backend-common';
import express from 'express';
import Router from 'express-promise-router';
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import { ScmIntegrations } from '@backstage/integration';
import {
getEntitySourceLocation,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { CatalogClient } from '@backstage/catalog-client';
import express from 'express';
import Router from 'express-promise-router';
import { isSymLink } from '../lib';

/**
Expand All @@ -34,7 +32,7 @@ export interface RouterOptions {
/**
* Backstage config object
*/
config: Config;
config: RootConfigService;

/**
* Backstage url reader instance
Expand Down Expand Up @@ -187,6 +185,7 @@ export async function createRouter(
});
});

router.use(errorHandler());
const middleware = MiddlewareFactory.create({ logger, config });
router.use(middleware.error());
return router;
}
50 changes: 0 additions & 50 deletions plugins/readme-backend/src/service/standaloneServer.ts

This file was deleted.

5 changes: 1 addition & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1530,20 +1530,17 @@ __metadata:
"@backstage/backend-common": "npm:^0.24.0"
"@backstage/backend-defaults": "npm:^0.4.3"
"@backstage/backend-plugin-api": "npm:^0.8.0"
"@backstage/backend-test-utils": "npm:^0.5.0"
"@backstage/catalog-client": "npm:^1.6.6"
"@backstage/catalog-model": "npm:^1.6.0"
"@backstage/cli": "npm:^0.27.0"
"@backstage/config": "npm:^1.2.0"
"@backstage/integration": "npm:^1.14.0"
"@backstage/plugin-permission-common": "npm:^0.8.1"
"@types/express": "npm:*"
"@types/supertest": "npm:^2.0.12"
express: "npm:^4.17.1"
express-promise-router: "npm:^4.1.0"
msw: "npm:^1.0.0"
node-fetch: "npm:^2.6.7"
supertest: "npm:^6.2.4"
yn: "npm:^4.0.0"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 176243f

Please sign in to comment.