-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add headers optional parameter to createClient and remove typecheckin…
…g on auth if there is a Authorization header (#852) Co-authored-by: Arda TANRIKULU <[email protected]>
- Loading branch information
1 parent
719d1fc
commit 40ff0b4
Showing
7 changed files
with
164 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'fets': patch | ||
--- | ||
|
||
Make auth params optional if they are provided in the client options as `globalParams` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createClient, createRouter, Response } from 'fets'; | ||
|
||
describe('Client Global Params', () => { | ||
it('should pass global params', async () => { | ||
const router = createRouter().route({ | ||
path: '/test', | ||
method: 'GET', | ||
handler: req => | ||
Response.json({ | ||
headers: Object.fromEntries(req.headers.entries()), | ||
query: req.query, | ||
}), | ||
}); | ||
const client = createClient<typeof router>({ | ||
fetchFn: router.fetch, | ||
globalParams: { | ||
headers: { | ||
'x-api-key': '123', | ||
}, | ||
query: { | ||
foo: 'bar', | ||
}, | ||
}, | ||
}); | ||
|
||
const res = await client['/test'].get(); | ||
|
||
expect(res.status).toBe(200); | ||
const data = await res.json(); | ||
expect(data.headers['x-api-key']).toBe('123'); | ||
expect(data.query['foo']).toBe('bar'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters