-
Notifications
You must be signed in to change notification settings - Fork 91
Improve HttpRequests
#1741
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
Improve HttpRequests
#1741
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1741 +/- ##
==========================================
+ Coverage 98.95% 99.36% +0.40%
==========================================
Files 16 16
Lines 1537 1566 +29
Branches 332 343 +11
==========================================
+ Hits 1521 1556 +35
+ Misses 16 10 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/clients/client.ts
Outdated
body: params, | ||
})) as EnqueuedTaskObject; | ||
|
||
return new EnqueuedTask(taks); | ||
} |
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.
bug: previously this did not return EnqueuedTask
, but rather EnqueuedTaskObject
tests/client.test.ts
Outdated
test(`${permission} key: Create client with custom headers (object)`, async () => { | ||
const key = await getKey(permission); | ||
const client = new MeiliSearch({ | ||
...config, | ||
apiKey: key, | ||
requestInit: { | ||
headers: { | ||
"Hello-There!": "General Kenobi", | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
assert.isTrue(await client.isHealthy()); | ||
|
||
assert.isDefined(fetchSpy.mock.lastCall); | ||
const [, requestInit] = fetchSpy.mock.lastCall!; | ||
|
||
assert.isDefined(requestInit?.headers); | ||
assert.instanceOf(requestInit!.headers, Headers); | ||
assert.strictEqual( | ||
(requestInit!.headers! as Headers).get("Hello-There!"), | ||
"General Kenobi", | ||
); | ||
}); |
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.
Because headers are internal implementation details, to check them we have to spy on fetch
now.
Alright, no problem, I just didn't know you guys talked before releasing. But to be fair I'm also excited to get my PRs merged 😅. |
Once v1.13 is out, merging your PR will be the priority @flevi29 😉 |
All good for me @flevi29. If you can fix the small conflicts, I'll get this merged. Thanks for the great work! |
@Strift fixed |
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.
Alright, let's do this 🔥
bors merge
Build succeeded:
|
Pull Request
Sorry for the huge PR, but
HttpRequests
is core, and is used everywhere.What does this PR do?
EnqueuedTaskObject
s not being converted toEnqueuedTask
Caution
BREAKING
Rename
Config.requestConfig
->Config.requestInit
,signal
can no longer be passed to it.Warning
Deprecate
Config.httpClient
#1824PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!