Skip to content

refactor(frontend) experiental PR to create an api client creation factory#566

Draft
Fbasham wants to merge 1 commit intomainfrom
fb-api-refac
Draft

refactor(frontend) experiental PR to create an api client creation factory#566
Fbasham wants to merge 1 commit intomainfrom
fb-api-refac

Conversation

@Fbasham
Copy link
Member

@Fbasham Fbasham commented Apr 2, 2025

MARKING AS DRAFT UNTIL FUNDING IS FIGURED OUT

Summary

This is an experimental PR to consolidate common functions and exporting HTTP clients in an api-client-factory module. Currently the application needs at least 2 HTTP clients. One for creating a case, and another for searching hitlist results/associating a SIN. This PR lays the ground work for that.

Types of changes

What types of changes does this PR introduce?
(check all that apply by placing an x in the relevant boxes)

  • 🛠️ refactoring -- non-breaking change that improves code readability or structure
  • 🐛 bugfix -- non-breaking change that fixes an issue
  • new feature -- non-breaking change that adds functionality
  • 💥 breaking change -- change that causes existing functionality to no longer work as expected
  • 📚 documentation -- changes to documentation only
  • ⚙️ build or tooling -- ex: CI/CD, dependency upgrades

Checklist

Before submitting this PR, ensure that you have completed the following. You can fill these out now, or after creating the PR.
(check all that apply by placing an x in the relevant boxes)

  • code has been linted and formatted locally
  • added or updated tests to verify the changes
  • added adequate logging for new or updated functionality
  • ensured metrics and/or tracing are in place for monitoring and debugging
  • documentation has been updated to reflect the changes (if applicable)
  • linked this PR to a related issue (if applicable)
Linting and formatting
npm run lint:check
npm run format:check
Unit and e2e tests
npm run test
npm run test:e2e

Additional Notes

If this PR introduces significant changes, explain your reasoning and provide any necessary context here. Feel free to include diagrams, screenshots, or alternative approaches you considered.

Screenshots (if applicable)

Provide screenshots or screen-recordings to help reviewers understand the visual impact of your changes, if relevant.

Comment on lines 84 to 94
export const interopClient = createTypedApiClient<InteropPaths>({
baseUrl: serverEnvironment.INTEROP_SIN_REG_API_BASE_URL,
authHeader: serverEnvironment.INTEROP_SIN_REG_API_AUTH_HEADER.value(),
proxyUrl: serverEnvironment.INTEROP_PROXY_URL,
});

export const powerPlatformClient = createTypedApiClient<PowerPlatformPaths>({
baseUrl: serverEnvironment.INTEROP_SIN_SEARCH_API_BASE_URL,
authHeader: serverEnvironment.INTEROP_SIN_SEARCH_API_AUTH_HEADER.value(),
proxyUrl: serverEnvironment.INTEROP_PROXY_URL,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These clients should not be created within the factory, as it introduces side effects. Instead, consider defining them in a separate module, such as api-clients, and using a function to retrieve them. If a singleton is preferred, lazy loading the client could be an option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated. Marking as draft until funding is figured out I guess.

@Fbasham Fbasham marked this pull request as draft April 2, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants