diff --git a/src/main/router.ts b/src/main/router.ts index 5be10cc888..bdd8317533 100644 --- a/src/main/router.ts +++ b/src/main/router.ts @@ -183,7 +183,6 @@ export class Router { this.router.add({ method: "delete", path: `${apiPrefix}/pods/port-forward/{namespace}/{resourceType}/{resourceName}` }, PortForwardRoute.routeCurrentPortForwardStop); // Helm API - this.router.add({ method: "get", path: `${apiPrefix}/v2/charts` }, HelmApiRoute.listCharts); this.router.add({ method: "get", path: `${apiPrefix}/v2/charts/{repo}/{chart}` }, HelmApiRoute.getChart); this.router.add({ method: "get", path: `${apiPrefix}/v2/charts/{repo}/{chart}/values` }, HelmApiRoute.getChartValues); diff --git a/src/main/routes/helm/charts/list-charts-route.injectable.ts b/src/main/routes/helm/charts/list-charts-route.injectable.ts new file mode 100644 index 0000000000..51ddcde94e --- /dev/null +++ b/src/main/routes/helm/charts/list-charts-route.injectable.ts @@ -0,0 +1,30 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import { routeInjectionToken } from "../../../router/router.injectable"; +import type { LensApiRequest } from "../../../router"; +import { helmService } from "../../../helm/helm-service"; +import { respondJson } from "../../../utils/http-responses"; +import { apiPrefix } from "../../../../common/vars"; + +const listChartsRouteInjectable = getInjectable({ + id: "list-charts-route", + + instantiate: () => ({ + method: "get", + path: `${apiPrefix}/v2/charts`, + + handler: async (request: LensApiRequest) => { + const { response } = request; + const charts = await helmService.listCharts(); + + respondJson(response, charts); + }, + }), + + injectionToken: routeInjectionToken, +}); + +export default listChartsRouteInjectable;