Skip to content

Commit 2c4bf01

Browse files
docs: remove duplications
1 parent 8bed7e9 commit 2c4bf01

16 files changed

Lines changed: 1251 additions & 1516 deletions

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ npm i -D apiful
2323

2424
## Usage
2525

26-
> [!TIP]
27-
> [📖 Read the documentation](https://apiful.land)
28-
2926
### Your First API Client
3027

3128
Create your first API client by initialising it with a base URL and a sample bearer token for authorization:
@@ -42,7 +39,7 @@ const client = createClient({
4239
```
4340

4441
> [!NOTE]
45-
> The `createClient` function returns an [`ApiClient`](https://apiful.land/reference/api-client) instance that does not yet have a call signature. You will need to add a base extension to the client in order to make API requests. Read on to learn how to do this.
42+
> The `createClient` function returns an [`ApiClient`](https://apiful.land/reference/api-client) instance that can't yet make requests. You'll need to add a handler extension to enable HTTP functionality. Read on to learn how to do this.
4643
4744
### Built-in Extensions
4845

@@ -88,7 +85,7 @@ await api.users.post({ name: 'foo' })
8885

8986
**What it does:**
9087

91-
The `apiRouterBuilder` provides a jQuery-like and Axios-esque API for building and making API requests. It allows you to construct your API calls in a declarative way.
88+
The `apiRouterBuilder` provides a jQuery-like and Axios-style API for building and making API requests. It allows you to construct your API calls in a declarative way.
9289

9390
</td></tr><tr><td width="500px" valign="top">
9491

@@ -150,7 +147,7 @@ const extendedClient = client
150147
extendedClient.logDefaults() // { baseURL: 'https://api.example.com', headers: { Authorization: 'Bearer <your-bearer-token>' } }
151148
```
152149

153-
If you have specific requirements that are not covered by the included extensions, you can create your own extensions. Follow the [Custom Extensions](https://apiful.land/guide/custom-extensions) guide to learn more.
150+
If you have specific requirements that aren't covered by the included extensions, you can create your own extensions. Follow the [Custom Extensions](https://apiful.land/guide/custom-extensions) guide to learn more.
154151

155152
## Development
156153

docs/extensions/api-router.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
> [!NOTE]
44
> This is a [handler extension](/guide/custom-extensions#handler-extension) and wraps [ofetch](https://github.com/unjs/ofetch) under the hood.
55
6-
The route builder extension gives you a jQuery-like and Axios-esque API to construct your API calls. This extension is particularly powerful for REST APIs with predictable URL patterns, as it generates zero runtime overhead for property access until you call an HTTP method, at which point it constructs the full URL path and delegates to the underlying HTTP client. This design makes it ideal for APIs with deep nesting (like `/api/v1/organizations/123/projects/456/tasks`) while maintaining excellent TypeScript intellisense throughout the chain:
6+
The route builder extension gives you a jQuery-like and Axios-style API to construct your API calls. This extension is particularly powerful for REST APIs with predictable URL patterns, as it generates zero runtime overhead for property access until you call an HTTP method, at which point it constructs the full URL path and delegates to the underlying HTTP client. This design makes it ideal for APIs with deep nesting (like `/api/v1/organizations/123/projects/456/tasks`) while maintaining excellent TypeScript intellisense throughout the chain:
77

88
```ts
99
// GET request to <baseURL>/users

docs/extensions/ofetch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
> [!NOTE]
44
> This is a [handler extension](/guide/custom-extensions#handler-extension) that wraps [ofetch](https://github.com/unjs/ofetch) under the hood.
55
6-
This built-in extension provides the most straightforward way to make HTTP requests with APIful. It wraps the battle-tested ofetch library with automatic JSON parsing, intelligent error handling, and request/response interception. Since it inherits all default options from the client, it is perfect for developers familiar with fetch or Axios who want enhanced capabilities without complexity.
6+
This built-in extension provides the most straightforward way to make HTTP requests with APIful. It wraps the battle-tested ofetch library with automatic JSON parsing, intelligent error handling, and request/response interception. Since it inherits all default options from the client, it's perfect for developers familiar with fetch or Axios who want enhanced capabilities without complexity.
77

88
Import the `ofetchBuilder` extension and add it to your client:
99

docs/extensions/openapi.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To use this extension, APIful must first generate TypeScript definitions from yo
99

1010
## Prerequisites
1111

12-
To keep the package size small, APIful does not include `openapi-typescript` as a dependency. Install the package using your preferred package manager:
12+
To keep the package size small, APIful doesn't include `openapi-typescript` as a dependency. Install the package using your preferred package manager:
1313

1414
::: code-group
1515
```bash [pnpm]
@@ -24,7 +24,7 @@ To keep the package size small, APIful does not include `openapi-typescript` as
2424
:::
2525

2626
> [!NOTE]
27-
> `openapi-typescript` is only needed during development for type generation. It will not be included in your production bundle.
27+
> `openapi-typescript` is only needed during development for type generation. It won't be included in your production bundle.
2828
2929
## TypeScript Definitions Generation
3030

@@ -55,7 +55,7 @@ The type generation process uses `openapi-typescript` to parse your OpenAPI sche
5555
Done! You can now use the `OpenAPIBuilder` extension to create a type-safe API client. Make sure you pass the **service name** to it as a generic parameter, such as `OpenAPIBuilder<'petStore'>()`. Follow the next chapter for more details.
5656

5757
> [!IMPORTANT]
58-
> Make sure the generated `apiful.d.ts` file is not excluded by your `tsconfig.json` configuration. TypeScript needs to find this file to provide typed definitions for your OpenAPI schema.
58+
> Make sure the generated `apiful.d.ts` file isn't excluded by your `tsconfig.json` configuration. TypeScript needs to find this file to provide typed definitions for your OpenAPI schema.
5959
6060
> [!TIP]
6161
> Run the generate command whenever your OpenAPI schema changes to keep your types up-to-date. Consider adding it to your build process or a pre-commit hook.
@@ -98,7 +98,7 @@ declare const userResponse: {
9898
9999
## OpenAPI Path Parameters
100100
101-
OpenAPI can define path parameters on given endpoints. They are typically declared as `/foo/{id}`. Unfortunately, the endpoint type is not defined as `/foo/10`. Thus, using the latter as the path will break type inference.
101+
OpenAPI can define path parameters on given endpoints. They are typically declared as `/foo/{id}`. Unfortunately, the endpoint type isn't defined as `/foo/10`. Thus, using the latter as the path will break type inference.
102102
103103
Instead, use the property `path` to pass an object of the parameters. You can then use the declared path for type inference, and the type checker will ensure you provide all required path parameters. The parameters will be interpolated into the path before the request is made.
104104
@@ -111,11 +111,11 @@ const response = await petStore('/foo/{id}', {
111111
```
112112

113113
> [!WARNING]
114-
> Incorrect parameters will not be reported at runtime. An incomplete path will be sent to the backend _as-is_.
114+
> Incorrect parameters won't be reported at runtime. An incomplete path will be sent to the backend _as-is_.
115115
116116
## Request Headers
117117

118-
Add headers to the request using the `headers` field. All headers defined in the OpenAPI schema will be type checked. You can still add additional headers that are not defined in the schema, which will not be type checked.
118+
Add headers to the request using the `headers` field. All headers defined in the OpenAPI schema will be type checked. You can still add additional headers that aren't defined in the schema, which won't be type checked.
119119

120120
```ts
121121
const response = await petStore('/some/endpoint', {

docs/guide/cli.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,7 @@ The CLI currently provides one primary command:
2222

2323
Generates TypeScript definitions from OpenAPI schemas. This is the core command for enabling type-safe API clients.
2424

25-
This command requires the `openapi-typescript` package, which APIful does not include by default to keep its package size small. Install the package using your preferred package manager:
26-
27-
::: code-group
28-
```bash [pnpm]
29-
pnpm add -D openapi-typescript
30-
```
31-
```bash [yarn]
32-
yarn add -D openapi-typescript
33-
```
34-
```bash [npm]
35-
npm install -D openapi-typescript
36-
```
37-
:::
25+
This command requires the `openapi-typescript` package. See the [OpenAPI extension prerequisites](/extensions/openapi#prerequisites) for installation instructions.
3826

3927
> [!IMPORTANT]
4028
> You must have a valid `apiful.config.ts` file with service definitions before running this command.
@@ -62,7 +50,7 @@ This displays the following output:
6250
<<< @/snippets/generate-help.ansi
6351

6452
> [!NOTE]
65-
> Although it is recommended to create an `apiful.config.ts` file with a [`defineApifulConfig`](/reference/define-apiful-config) default export, you can also write plain JavaScript (`.js`, `.mjs`, `.cjs`) or JSON (`.json`, `.json5`) configuration files.
53+
> Although it's recommended to create an `apiful.config.ts` file with a [`defineApifulConfig`](/reference/define-apiful-config) default export, you can also write plain JavaScript (`.js`, `.mjs`, `.cjs`) or JSON (`.json`, `.json5`) configuration files.
6654
6755
#### Fragmented Output
6856

docs/guide/custom-extensions.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ APIful's true power lies in its extensibility. You can chain multiple extensions
44

55
## Extension Types
66

7-
Before creating your first extension, it is essential to understand the two types of extensions available.
8-
9-
APIful provides two types of extensions:
10-
11-
- **Handler Extension**: Adds the callable signature to a client instance (e.g., `client('/path')`). This provides the core HTTP functionality.
12-
- **Methods Extension**: Adds methods to the client instance (e.g., `client.login()`, `client.cache.get()`). You can chain multiple method extensions.
13-
14-
Both extension types are created using a builder function that receives the client instance and returns the extension function (handler) or object (methods). This builder pattern serves two essential purposes: it provides access to the client instance for reading default options and existing extensions, and it enables TypeScript's type inference to work correctly across the extension chain.
7+
Before creating your first extension, make sure you understand the [two types of extensions](/guide/extension-types) available: handler extensions (callable signature) and methods extensions (additional methods).
158

169
> [!IMPORTANT]
1710
> Use `satisfies HandlerExtensionBuilder` or `satisfies MethodsExtensionBuilder` instead of declaring extension variables directly with these types. The `satisfies` operator is crucial here – it validates that your extension conforms to the expected interface while preserving the exact return type for downstream type inference, ensuring seamless integration with other extensions.

docs/guide/getting-started.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## What Is This?
44

5-
APIful provides a unified interface to manage all your API interactions by setting up a client with default fetch options, such as the base API URL and headers. Extensions add a variety of features to the client through a sophisticated proxy-based architecture that maintains full TypeScript type safety while allowing runtime composition. This approach ensures that each extension can enhance or override behavior without breaking the client contract, while keeping bundle sizes minimal through intelligent tree-shaking.
5+
APIful provides a unified interface to manage all your API interactions by setting up a client with default fetch options, such as the base API URL and headers. Extensions add a variety of features to the client while maintaining full TypeScript type safety. Learn more about [how extensions work](/guide/using-extensions#how-extensions-work).
66

77
You can use one of the [built-in extensions](/guide/using-extensions#built-in-extensions) to get started right away, or create your own [custom extension](/guide/custom-extensions) to meet your specific needs.
88

@@ -23,7 +23,7 @@ Get started by installing `apiful` in your project:
2323
:::
2424

2525
> [!TIP]
26-
> APIful is designed as a development dependency since it is primarily used for generating types and building API clients during your build process.
26+
> APIful is designed as a development dependency since it's primarily used for generating types and building API clients during your build process.
2727
2828
## Your First API Client
2929

@@ -41,7 +41,7 @@ const client = createClient({
4141
```
4242

4343
> [!NOTE]
44-
> The `createClient` function returns an [`ApiClient`](/reference/api-client) instance that cannot yet make requests. You will need to add a handler extension to enable HTTP functionality.
44+
> The `createClient` function returns an [`ApiClient`](/reference/api-client) instance that can't yet make requests. You'll need to add a handler extension to enable HTTP functionality.
4545
4646
## Choose a Built-in Extension
4747

@@ -105,12 +105,8 @@ const extendedClient = client
105105
extendedClient.logDefaults() // { baseURL: 'https://api.example.com', headers: { Authorization: 'Bearer <your-bearer-token>' } }
106106
```
107107

108-
## Error Handling Across Extensions
109-
110-
Each extension can implement its own error handling strategy, and errors propagate through the extension chain in a predictable manner. The ofetch extension automatically throws detailed errors with status codes and response bodies, while custom extensions can implement retry logic, circuit breakers, or custom error transformation. This layered approach allows higher-level extensions to catch and transform errors from lower-level ones, giving you complete control over how your application handles API failures.
111-
112108
> [!IMPORTANT]
113109
> When chaining multiple extensions, later extensions override methods from earlier ones. This gives you fine-grained control over the final client behavior.
114110
115111
> [!TIP]
116-
> If you have specific requirements that are not covered by the included extensions, you can create your own extensions. Follow the [Custom Extensions](/guide/custom-extensions) guide to learn more.
112+
> If you have specific requirements that aren't covered by the included extensions, you can create your own extensions. Follow the [Custom Extensions](/guide/custom-extensions) guide to learn more.

docs/guide/using-extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const client = createClient({
1717
```
1818

1919
> [!IMPORTANT]
20-
> The client by itself cannot make requests - you need at least one handler extension to provide the actual HTTP functionality.
20+
> The client by itself can't make requests you need at least one handler extension to provide the actual HTTP functionality.
2121
2222
> [!TIP]
2323
> Default options are automatically passed to all extensions, ensuring consistent configuration across your entire client.
@@ -42,7 +42,7 @@ Choose the extension that best fits your use case and personal preference:
4242
- **[API Router](/extensions/api-router)** - jQuery/Axios-style chaining with `client.users.get()`
4343

4444
> [!TIP]
45-
> Start with the ofetch extension if you are new to APIful - it provides the most familiar API for developers coming from fetch or Axios.
45+
> Start with the ofetch extension if you're new to APIful it provides the most familiar API for developers coming from fetch or Axios.
4646
4747
## Custom Extensions
4848

docs/reference/create-openapi-client.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,13 @@ Creates a type-safe OpenAPI client directly without using the APIful extension s
77
Use `createOpenAPIClient` when you:
88

99
- Want a direct, lightweight OpenAPI client
10-
- Don not need the extensibility features of the main APIful client system
10+
- Don't need the extensibility features of the main APIful client system
1111
- Prefer a simpler API without the `.with()` extension pattern
1212
- Want to avoid the additional abstraction layer
1313

1414
## Prerequisites
1515

16-
Same as the [`OpenAPIBuilder`](/extensions/openapi) extension:
17-
18-
::: code-group
19-
```bash [pnpm]
20-
pnpm add -D openapi-typescript
21-
```
22-
```bash [yarn]
23-
yarn add -D openapi-typescript
24-
```
25-
```bash [npm]
26-
npm install -D openapi-typescript
27-
```
28-
:::
29-
30-
You also need to generate TypeScript definitions using the [`generate`](/guide/cli) command.
16+
Same as the [`OpenAPIBuilder`](/extensions/openapi#prerequisites) extension – you need `openapi-typescript` installed and TypeScript definitions generated using the [`generate`](/guide/cli) command.
3117

3218
## Example
3319

@@ -59,21 +45,6 @@ const userResponse = await petStore('/user/{username}', {
5945
| API complexity | ✅ Simple, direct API | ❌ More complex setup |
6046
| Customization | ❌ Limited to fetch options | ✅ Unlimited via extensions |
6147

62-
## Example
63-
64-
```ts
65-
import { createOpenAPIClient } from 'apiful'
66-
67-
const petStore = createOpenAPIClient<'petStore'>({
68-
baseURL: 'https://petstore3.swagger.io/api/v3',
69-
})
70-
71-
const userResponse = await petStore('/user/{username}', {
72-
method: 'GET',
73-
path: { username: 'user1' },
74-
})
75-
```
76-
7748
## Type Definition
7849

7950
```ts

docs/utilities/http-status-codes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ APIful provides all common HTTP status codes as constants. These are individuall
55
All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), RFC2518 (WebDAV), RFC6585 (Additional HTTP Status Codes), and RFC7538 (Permanent Redirect) are supported.
66

77
> [!TIP]
8-
> You may be wondering, why not use the [http-status-codes](https://www.npmjs.com/package/http-status-codes) package directly? Because the enums exported by the package do not work well with frameworks like Hono that use the `@hono/zod-openapi` type system.
8+
> You may be wondering, why not use the [http-status-codes](https://www.npmjs.com/package/http-status-codes) package directly? Because the enums exported by the package don't work well with frameworks like Hono that use the `@hono/zod-openapi` type system.
99
1010
## Usage
1111

0 commit comments

Comments
 (0)