-
Notifications
You must be signed in to change notification settings - Fork 5
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(http): interceptor API #29
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.
Haven't tested it yet, but code LGTM! Nice work!
For some reason this test fails for me locally but passes on the CI: ● StrapiSDK › Custom Interceptors › HTTP › fetch should add an application/json Content-Type header to each request
expect(received).toBe(expected) // Object.is equality
Expected: "application/json"
Received: null
190 | expect(headers).toBeDefined();
191 | expect(headers).toBeInstanceOf(Headers);
> 192 | expect((headers as Headers).get('Content-Type')).toBe('application/json');
| ^
193 | });
194 |
195 | it.each([
at Object.<anonymous> (tests/unit/sdk.test.ts:192:58) Update: it fails on Node 20.9.0 but works on 20.12.0, maybe we're relying on a feature that wasn't added until after 20.9? |
It seems that a fix has been released after 20.9.0, I've constrained the SDK usage to the latest v20 release as it's in maintenance anyway. Everything should now be working |
Note: I've also updated the version for some of our outdated packages while I was there |
What does it do?
Major Changes
HttpClient
to theStrapiSDK
to remove dependency issues (for example,HttpClient
shouldn't know about theAuthManager
). Now the core logic is handled by the SDK itself.Minor Changes
get
,put
,post
anddelete
methods for the HTTP modulePathFormatter
class to facilitate validation and transformation of common paths (baseURL
, requests path, etc...)Why is it needed?
Groundwork for next features (user API), clean up imperfections in the architecture, and fix how modules communicate/rely on each other.
How to test it?
DEBUG=* node index.js
) to check if all the requests are done correctlyYou should end up with something similar to this:
Bundle Size Evolution
The bundle grew quite a lot, but this is to be expected in the first few refactor and big features we're gonna introduce at the beginning as we add the main elements powering future capabilities.
Also, not sure why the browser build doesn't grow 🤔
dist/bundle.browser.min.js
dist/bundle.cjs.js
dist/bundle.esm.js