Skip to content

Commit

Permalink
feat(explore): remove support for old backend system (#2212)
Browse files Browse the repository at this point in the history
* feat(explore): remove support for old backend system

Signed-off-by: secustor <[email protected]>

* docs(explore): update docs

Signed-off-by: secustor <[email protected]>

* fixup lockfile

Signed-off-by: secustor <[email protected]>

---------

Signed-off-by: secustor <[email protected]>
Co-authored-by: Yash Oswal <[email protected]>
  • Loading branch information
secustor and yashoswalyo authored Jan 3, 2025
1 parent 59cab9a commit 088f904
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 290 deletions.
5 changes: 5 additions & 0 deletions workspaces/explore/.changeset/honest-bottles-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-explore-backend': minor
---

Remove support for old backend system
154 changes: 0 additions & 154 deletions workspaces/explore/plugins/explore-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,116 +40,6 @@ explore:
- nerdGraph
```
### Adding the plugin to your `packages/backend` (old)

#### Tools as Config

Install dependencies

```bash
# From your Backstage root directory
yarn --cwd packages/backend add @backstage-community/plugin-explore-backend
```

You'll need to add the plugin to the router in your `backend` package. You can
do this by creating a file called `packages/backend/src/plugins/explore.ts` with the following content:

```ts title="packages/backend/src/plugins/explore.ts"
import {
createRouter,
StaticExploreToolProvider,
} from '@backstage-community/plugin-explore-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
toolProvider: StaticExploreToolProvider.fromConfig(env.config),
});
}
```

Config:

```yaml
explore:
tools:
- title: New Relic
description: new relic plugin
url: /newrelic
image: https://i.imgur.com/L37ikrX.jpg
tags:
- newrelic
- proxy
- nerdGraph
```

#### Tools as Code

Install dependencies

```bash
# From your Backstage root directory
yarn --cwd packages/backend add @backstage-community/plugin-explore-backend @backstage-community/plugin-explore-common
```

You'll need to add the plugin to the router in your `backend` package. You can
do this by creating a file called `packages/backend/src/plugins/explore.ts` with the following content:

```ts
import {
createRouter,
StaticExploreToolProvider,
} from '@backstage-community/plugin-explore-backend';
import { ExploreTool } from '@backstage-community/plugin-explore-common';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
// List of tools you want to surface in the Explore plugin "Tools" page.
const exploreTools: ExploreTool[] = [
{
title: 'New Relic',
description: 'new relic plugin',
url: '/newrelic',
image: 'https://i.imgur.com/L37ikrX.jpg',
tags: ['newrelic', 'proxy', 'nerdGraph'],
},
];
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
toolProvider: StaticExploreToolProvider.fromData(exploreTools),
});
}
```

#### Register the plugin router

With the `explore.ts` router setup in place, add the router to
`packages/backend/src/index.ts`:

```diff
+import explore from './plugins/explore';
async function main() {
...
const createEnv = makeCreateEnv(config);
const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
+ const exploreEnv = useHotMemoize(module, () => createEnv('explore'));
const apiRouter = Router();
+ apiRouter.use('/explore', await explore(exploreEnv));
...
apiRouter.use(notFoundHandler());
```

### Wire up Search Indexing
To index explore tools you will need to register the search collator in the
Expand Down Expand Up @@ -184,50 +74,6 @@ can be customized to provide tools from any source. For example you could create
a `CustomExploreToolProvider` that queries an internal for tools in your
`packages/backend/src/plugins/explore.ts` file.

Old Backend system:

```ts
import {
createRouter,
StaticExploreToolProvider,
} from '@backstage-community/plugin-explore-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
class CustomExploreToolProvider implements ExploreToolProvider {
async getTools(
request: GetExploreToolsRequest,
): Promise<GetExploreToolsResponse> {
const externalTools = await queryExternalTools(request);
const tools: ExploreTool[] = [
...externalTools,
// Backstage Tools
{
title: 'New Relic',
description: 'new relic plugin',
url: '/newrelic',
image: 'https://i.imgur.com/L37ikrX.jpg',
tags: ['newrelic', 'proxy', 'nerdGraph'],
},
];
return { tools };
}
}
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
toolProvider: new CustomExploreToolProvider(),
});
}
```

New Backend system:

```ts
// packages/backend/src/modules/exploreToolProviderModule.ts
Expand Down
1 change: 0 additions & 1 deletion workspaces/explore/plugins/explore-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"dependencies": {
"@backstage-community/plugin-explore-common": "workspace:^",
"@backstage-community/plugin-explore-node": "workspace:^",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-plugin-api": "^1.1.0",
"@backstage/config": "^1.3.1",
"@backstage/types": "^1.2.0",
Expand Down
13 changes: 0 additions & 13 deletions workspaces/explore/plugins/explore-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ExploreTool } from '@backstage-community/plugin-explore-common';
import { ExploreToolProvider as ExploreToolProvider_2 } from '@backstage-community/plugin-explore-node';
import express from 'express';
import { GetExploreToolsRequest } from '@backstage-community/plugin-explore-common';
import { GetExploreToolsResponse } from '@backstage-community/plugin-explore-common';
import { LoggerService } from '@backstage/backend-plugin-api';

// @public @deprecated (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;

// @public
const explorePlugin: BackendFeature;
Expand All @@ -22,14 +17,6 @@ export default explorePlugin;
// @public @deprecated (undocumented)
export type ExploreToolProvider = ExploreToolProvider_2;

// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
logger: LoggerService;
// (undocumented)
toolProvider: ExploreToolProvider_2;
}

// @public
export class StaticExploreToolProvider implements ExploreToolProvider_2 {
// (undocumented)
Expand Down
1 change: 0 additions & 1 deletion workspaces/explore/plugins/explore-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

export { explorePlugin as default } from './plugin';
export * from './service';
export * from './tools';

/**
Expand Down
13 changes: 0 additions & 13 deletions workspaces/explore/plugins/explore-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,17 @@
* limitations under the License.
*/

import { errorHandler } from '@backstage/backend-common';
import { GetExploreToolsRequest } from '@backstage-community/plugin-explore-common';
import express from 'express';
import Router from 'express-promise-router';
import { LoggerService } from '@backstage/backend-plugin-api';
import { ExploreToolProvider } from '@backstage-community/plugin-explore-node';

/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public
*/
export interface RouterOptions {
logger: LoggerService;
toolProvider: ExploreToolProvider;
}

/**
* @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 All @@ -50,8 +39,6 @@ export async function createRouter(
response.json(result);
});

router.use(errorHandler());

return router;
}

Expand Down
Loading

0 comments on commit 088f904

Please sign in to comment.