diff --git a/docs/v1/create-client.md b/docs/v1/create-client.md index ab79470..4f8f02b 100644 --- a/docs/v1/create-client.md +++ b/docs/v1/create-client.md @@ -58,18 +58,26 @@ type ClientConfig = { }; ``` -## Supported request methods +## HTTP methods -The client provides these convenience methods: +The client provides a predictable set of methods: -- client.get(path, options?) -- client.post(path, body?, options?) -- client.put(path, body?, options?) -- client.delete(path, options?) +```text +client.get(path, options?) +client.delete(path, options?) -It also provides: +client.post(path, body?, options?) +client.put(path, body?, options?) +client.patch(path, body?, options?) -- client.request(config) +client.request(config) +``` + +### Body vs options + +- `get` and `delete` do not accept body +- `post`, `put`, and `patch` accept request body as the second argument +- `options` is used for headers, query, timeout, retry, and other settings ## GET request @@ -110,13 +118,33 @@ const updated = await client.put('/users/1', { }); ``` +## PATCH request + +```ts +const updatedUser = await client.patch('/users/1', { + name: 'Jane', +}); +``` + ## DELETE request ```ts const result = await client.delete('/users/1'); ``` -## Low-level request API +## Request options + +```ts +type RequestOptions = { + query?: Record; + headers?: Record; + timeout?: number; + retry?: RetryConfig; + signal?: AbortSignal; +}; +``` + +## Low-level request ```ts const result = await client.request({ @@ -132,28 +160,18 @@ const result = await client.request({ }); ``` -## Request options - -For `get()` and `delete()`: - -```ts -type RequestOptions = { - query?: Record; - headers?: Record; - timeout?: number; -}; -``` - -For `request()`: +### Request Config ```ts type RequestConfig = { - method: 'GET' | 'POST' | 'PUT' | 'DELETE'; + method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; path: string; query?: Record; body?: unknown; headers?: Record; timeout?: number; + retry?: RetryConfig; + signal?: AbortSignal; }; ``` diff --git a/docs/v1/examples.md b/docs/v1/examples.md index 3085eba..cfa6867 100644 --- a/docs/v1/examples.md +++ b/docs/v1/examples.md @@ -8,13 +8,13 @@ const client = createClient({ }); ``` -## GET request +## GET method ```ts const users = await client.get('/users'); ``` -## POST JSON +## POST method ```ts const createdUser = await client.post('/users', { @@ -22,6 +22,29 @@ const createdUser = await client.post('/users', { }); ``` +## PATCH method + +```ts +const updatedUser = await client.patch('/users/1', { + name: 'Jane', +}); +``` + +## DELETE method + +```ts +const deletedUser = await client.delete('/users/1'); +``` + +## Low-level request + +```ts +const singleUser = await client.request({ + method: 'GET', + path: '/users/2', +}); +``` + ## Client with auth ```ts diff --git a/docs/v1/getting-started.md b/docs/v1/getting-started.md index 825a19f..ec38c0f 100644 --- a/docs/v1/getting-started.md +++ b/docs/v1/getting-started.md @@ -18,10 +18,11 @@ The client focuses on predictable behavior, extensibility, and a clean developer - request timeout support - automatic JSON parsing - text response support -- structured error classes -- auth support -- lifecycle hooks -- retry support +- consistent error handling with structured error classes +- auth support: `bearer`, `API key` and custom +- lifecycle hooks: `beforeRequest`, `afterResponse`, `onError` +- support for `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` +- retry policies - custom `fetch` support ## Quick example diff --git a/src/components/ProjectBadges/ProjectBadges.tsx b/src/components/ProjectBadges/ProjectBadges.tsx index 67d0704..c5793ac 100644 --- a/src/components/ProjectBadges/ProjectBadges.tsx +++ b/src/components/ProjectBadges/ProjectBadges.tsx @@ -31,7 +31,7 @@ export const ProjectBadges = () => { >