feat(client): support http method in req middleware (#87)

* feat(client): support http method in req middleware

* fix(client): fix required property
This commit is contained in:
Daniel Rochetti 2024-09-19 08:19:09 -07:00 committed by GitHub
parent 4da11f3060
commit 39089b2462
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "@fal-ai/serverless-client", "name": "@fal-ai/serverless-client",
"description": "The fal serverless JS/TS client", "description": "The fal serverless JS/TS client",
"version": "0.14.2", "version": "0.14.3",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -3,12 +3,13 @@
* *
* **Note:** This is a simplified version of the `RequestConfig` type from the * **Note:** This is a simplified version of the `RequestConfig` type from the
* `fetch` API. It contains only the properties that are relevant for the * `fetch` API. It contains only the properties that are relevant for the
* `fal-serverless` client. It also works around the fact that the `fetch` API * fal client. It also works around the fact that the `fetch` API `Request`
* `Request` does not support mutability, its clone method has critical limitations * does not support mutability, its clone method has critical limitations
* to our use case. * to our use case.
*/ */
export type RequestConfig = { export type RequestConfig = {
url: string; url: string;
method: string;
headers?: Record<string, string | string[]>; headers?: Record<string, string | string[]>;
}; };

View File

@ -30,6 +30,7 @@ export async function dispatchRequest<Input, Output>(
const { url, headers } = await requestMiddleware({ const { url, headers } = await requestMiddleware({
url: targetUrl, url: targetUrl,
method: method.toUpperCase(),
}); });
const authHeader = credentials ? { Authorization: `Key ${credentials}` } : {}; const authHeader = credentials ? { Authorization: `Key ${credentials}` } : {};
const requestHeaders = { const requestHeaders = {