-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add fetch override #245
feat: add fetch override #245
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I really appreciate the effort here.
The only issue with this is that it is a breaking change and we're not ready to add another major version to our release channel. I would encourage you to add a new property (not breaking) like fetchClient
.
I would then replace fetchWithAuth
with a function that switched Fetch if it was supplied, and then called fetchWithAuth to return a preconfigured fetch instance using the right class and the auth headers.
Superbase has a good example, and they use cross-fetch too https://github.com/supabase/supabase-js/blob/master/src/lib/fetch.ts#L6
Also any tests you're able to provide would be very helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clicked approve on the wrong PR. Should have been this one:
#246 (review)
@lukeocodes understood, my thinking was that it'll be a bit confusing to have regarding tests, I personally am not a fan of testing protected methods so the only option I see is to add tests like that to each client type
wdyt? |
Looks good to me! I'm going to personally test this on browsers, edge functions and Node environments to ensure we're not introducing a regression. I'll try and get this reviewed by the end of the week. Really appreciate you coming back with fixes for the PR |
@lukeocodes awesome, please let me know if there's anything missing! |
Any update on this? Would be great to also see an example somewhere of a custom fetch impl to use - trying to workaround the 5 mins timeout errors of the default nodejs fetch |
@pkpio I added some examples here https://github.com/BartoszJarocki/deepgram-js-sdk-custom-fetch/blob/main/index.ts |
Your test looks good, it could be added to https://github.com/deepgram/deepgram-js-sdk/blob/main/test/client.test.ts if I am not mistaken.. |
I'll calve out time to review and test this next week! |
Hello here is some example working code using an AbortController
To use the custom fetch pull request, I used the following The forceApikey mechanism allows a deepgram client to tell a deepgram proxy to use a different API key, it is described in the deepgram http proxy project., though no deepgram proxy implementation has been published yet IMHO. |
I am about to release a product with this fork...
|
i want to avoid taking any new namespaces while i think about the best way to do this
@BartoszJarocki thanks for your patience on this. If you could please add the test just as you had it, that will be great. FYI, I have modified the namespace of the custom fetch to Once we have the test, this is good to go. You can add it to |
@lukeocodes I'm glad it's good to go! I just added a test 84a4e27. |
Sweet. I'll just double check some stuff, might cut a release today all
being well and having a colleague available to check a box 😇
Thanks again for your help and patience! I appreciate it's been sitting
here for a month or two, while we we cleared our plates!
…On Thu, 25 Apr 2024, 18:13 Bartosz Jarocki, ***@***.***> wrote:
@lukeocodes <https://github.com/lukeocodes> I'm glad it's good to go! I
just added a test 84a4e27
<84a4e27>
.
—
Reply to this email directly, view it on GitHub
<#245 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHJPAWM7NC5MPSLWEZOFBLY7E2U5AVCNFSM6AAAAABCXGBSRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZXG43TMNRRGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
awesome, sounds good! |
* feat: add _experimentalCustomFetch config to override fetch (#245) * feat: allow to provide custom fetch method to AbstractRestfulClient * fix: allow to provide both fetch and fetch options * refactor: init custom fetch in resolveFetch * rename `customFetch` to `_experimentalCustomFetch` i want to avoid taking any new namespaces while i think about the best way to do this * use `_experimentalCustomFetch` instead of `customFetch` for fetch override * test: added custom fetch test --------- Co-authored-by: Luke Oliff <luke@lukeoliff.com> * chore: Bump es5-ext from 0.10.62 to 0.10.64 (#250) Bumps [es5-ext](https://github.com/medikoo/es5-ext) from 0.10.62 to 0.10.64. - [Release notes](https://github.com/medikoo/es5-ext/releases) - [Changelog](https://github.com/medikoo/es5-ext/blob/main/CHANGELOG.md) - [Commits](medikoo/es5-ext@v0.10.62...v0.10.64) --- updated-dependencies: - dependency-name: es5-ext dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add get auth token details method to manage client (#262) * chore: edit example for is_final and endpointing together with utterance end (#264) * fix: add missing expiration_date to CreateProjectKeyResponse (#265) * fix: update user agent to include JS or node (#269) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Bartosz Jarocki <bartosz.jarocki@hey.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: DamienDeepgram <138720050+DamienDeepgram@users.noreply.github.com> Co-authored-by: Lachlan Donald <lachlan@ljd.cc>
Now using the 3.3.0 version, with a unit test to ensure the experimental custom fetch parameter keeps working before releasing myself. Thank you @BartoszJarocki @lukeocodes !! |
Thanks again! I have now (now that I have some time) been looking at a long term solution for transmitter overrides (websocket and fetch), custom headers, namespaced config per product (transcription and speech intelligence can operate differently), etc, etc. I have a good solution that is backwards compatible, and will maintain compatibility with the experimental property we included here. Mind if I include you in the review of it when it is ready? |
Good! |
This PR renames
fetch
tofetchOptions
and adds an additional option to provide own fetch method.fixes #243