Skip to content

Commit 44bb58f

Browse files
refactor: simplify bragi client to follow brokkr pattern
Remove BragiClient class and use function-based approach instead. - Replace BragiClient class with parseFeedback helper function - Keep getBragiClient function for getting client instance - Remove unused IBragiClient interface and types.ts file - Update exports to only expose function-based API This matches the pattern used by other service clients like Brokkr. Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
1 parent e10fa54 commit 44bb58f

3 files changed

Lines changed: 8 additions & 33 deletions

File tree

src/integrations/bragi/clients.ts

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import {
66
ParseFeedbackRequest,
77
ParseFeedbackResponse,
88
} from '@dailydotdev/schema';
9-
import { GarmrService, IGarmrService } from '../garmr';
9+
import { GarmrService } from '../garmr';
1010
import type { ServiceClient } from '../../types';
11-
import { IBragiClient } from './types';
1211

1312
const garmrBragiService = new GarmrService({
1413
service: 'bragi',
@@ -33,24 +32,9 @@ export const getBragiClient = (
3332
};
3433
};
3534

36-
export class BragiClient implements IBragiClient {
37-
private readonly client: ServiceClient<typeof Pipelines>;
38-
39-
constructor(
40-
private readonly garmr: IGarmrService = garmrBragiService,
41-
clientTransport = transport,
42-
) {
43-
this.client = {
44-
instance: createClient<typeof Pipelines>(Pipelines, clientTransport),
45-
garmr: this.garmr,
46-
};
47-
}
48-
49-
parseFeedback(request: ParseFeedbackRequest): Promise<ParseFeedbackResponse> {
50-
return this.garmr.execute(() =>
51-
this.client.instance.parseFeedback(request),
52-
);
53-
}
54-
}
55-
56-
export const bragiClient = new BragiClient(garmrBragiService);
35+
export const parseFeedback = async (
36+
request: ParseFeedbackRequest,
37+
): Promise<ParseFeedbackResponse> =>
38+
garmrBragiService.execute(async () =>
39+
getBragiClient().instance.parseFeedback(request),
40+
);

src/integrations/bragi/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export * from './types';
2-
export { BragiClient, bragiClient } from './clients';
1+
export { getBragiClient, parseFeedback } from './clients';

src/integrations/bragi/types.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)