Skip to content

Commit

Permalink
fix(notifications): use baseUrl from configuration (#1092)
Browse files Browse the repository at this point in the history
  • Loading branch information
mareklibra authored Jan 21, 2024
1 parent b7a9dc0 commit eed63a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion plugins/notifications/src/api/NotificationsApiImpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchApi } from '@backstage/core-plugin-api';
import { ConfigApi, FetchApi } from '@backstage/core-plugin-api';

import {
Configuration,
Expand All @@ -15,14 +15,19 @@ import {

export type NotificationsApiOptions = {
fetchApi: FetchApi;
configApi: ConfigApi;
};

export class NotificationsApiImpl implements NotificationsApi {
private readonly backendRestApi: NotificationsOpenApi;

constructor(options: NotificationsApiOptions) {
const backendUrl = options.configApi.getString('backend.baseUrl');
const basePath = `${backendUrl}/api/notifications`;

const configuration = new Configuration({
fetchApi: options.fetchApi.fetch,
basePath,
});
this.backendRestApi = new NotificationsOpenApi(configuration);
}
Expand Down
7 changes: 4 additions & 3 deletions plugins/notifications/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
configApiRef,
createApiFactory,
createPlugin,
createRoutableExtension,
fetchApiRef,
// identityApiRef,
} from '@backstage/core-plugin-api';

import { NotificationsApiImpl, notificationsApiRef } from './api';
Expand All @@ -17,10 +17,11 @@ export const notificationsPlugin = createPlugin({
apis: [
createApiFactory({
api: notificationsApiRef,
deps: { fetchApi: fetchApiRef },
factory({ fetchApi }) {
deps: { fetchApi: fetchApiRef, configApi: configApiRef },
factory({ fetchApi, configApi }) {
return new NotificationsApiImpl({
fetchApi,
configApi,
});
},
}),
Expand Down

0 comments on commit eed63a9

Please sign in to comment.